|
Home > Archive > Microsoft SQL Server forum > September 2005 > Why dosn't IIF work here?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Why dosn't IIF work here?
|
|
| metcarob 2005-09-15, 7:23 am |
| Hi,
I have the following query: (Simplified version for testing)
SELECT IIF(MonAM='S','YES',
'NO') as IsSick
FROM tblAbsence
This works prfectly in Access, SQL Server won't like it.
I have tried every alteration I can think of but still nothing.
This is so simple I can't believe I can't get it working.
Can anyone tell me what's wrong and let me know what I should be doing
to obtain this functionality?
Thanks
Robert
| |
|
| SQL Server has no idea about IIF, here you have to refer to CASE. (BOL)
SELECT CASE MonAM WHEN 'S' THEN 'YES' ELSE 'NO' END as IsSick
FROM tblAbsence
HTH, Jens Suessmeyer.
| |
| Simon Hayes 2005-09-15, 7:23 am |
| IIF exists only in Access, not MSSQL. The SQL equivalent is CASE - see
Books Online for examples.
Simon
| |
| dbahooker@hotmail.com 2005-09-28, 11:23 am |
| tsql is a LOT more powerful and exciting than access.. i hope you stick
with mssql.. it's a lot of fun
|
|
|
|
|