Is there any better way to write the lines below in SQL Server 2005?
CASE
WHEN (ID IS NULL)
THEN 'YES'
WHEN (ID IS NOT NULL)
THEN 'NO'
END AS ID_Value,
|
Is there any better way to write the lines below in SQL Server 2005?
|
||||
| show 2 more comments |
|
Did you try:
I only have access to 2008 right now, but I'd hope that this syntax would still work in 2005 (seems like something that would be part of the original definition of |
|||||||||||
|
IF(ID IS NULL, 'YES', 'NO') AS ID_Value– Kondybas Jul 11 '12 at 6:54IIFbut the question is tagged 2005. – Martin Smith Jul 11 '12 at 6:56isnull(nullif(isnull(ID,'Y'),ID),'N')– Jason Cumberland Jul 12 '12 at 16:24IDis a string, of course. Otherwise this expression should be elongated a little more by a call toCASTorCONVERT. – Andriy M Jul 12 '12 at 18:30