I am getting some fields back from a select statement, how do you check one of the fields and display a string depending on what it is? Is there something like an if statement you can use? for example
select
field1,
field2 /*how do you check to see what it is here and display something depending on what it is*/
from
record
I am trying to see if field2 is a '' or empty string character
thxYou use a CASE statement.
SELECT field1, CASE field2 WHEN '' THEN 'BLANK' ELSE field2 END as Field2 FROM Table
If rather than '' the value might be null, you can use ISNULL
|||thank you for the help
SELECT field1, ISNULL(field2,'BLANK') as field2 FROM Table
No comments:
Post a Comment