In your example, you were trying to add IIF() to IsNull(), which already
does what you want:
SELECT FirstName, Lastname, TelephoneNumber,
IsNull(TelephoneInstructions, "Any Time") as [When to Contact]
FROM db1.ContactInfo
This is functionally equivalent to
SELECT FirstName, Lastname, TelephoneNumber,
CASE WHEN TelephoneInstructions IS NULL THEN 'Any Time'
ELSE TelephoneInstructions END as [When to Contact]
FROM db1.ContactInfo
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box! |
*************************************************
Jonathan Wood said:
Actually, I found this example at
http://msdn2.microsoft.com/en-us/library/ms181765.aspx:
SELECT FirstName, Lastname, TelephoneNumber,
IIf(IsNull(TelephoneInstructions),"Any time",
TelephoneInstructions) AS [When to Contact]
FROM db1.ContactInfo
But when I do something similar I get an error about ISNULL() requiring
two arguments.
Any tips?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood said:
I found IIF(), which looks like that should work. (Didn't see it before
because it doesn't turn blue in the editor indicating a keyword.)
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Is there a SELECT syntax for returning 1 if a particular column is
NULL, or 0 if the column is not NULL?
I found ISNULL(), but that returns the column if it is not NULL where
I'd want to return 1. I also found IS NULL but couldn't see a way to
use that either.
Thanks.