September 14, 2004 at 12:41 pm
How do I indicate durring selection that if something is null then it should be a 1 or a 0?
if example IS NULL then 1 Else example
"The grass is always greener over the septic tank." ~Leaf
September 14, 2004 at 1:15 pm
SELECT ISNULL( example, 1 ) FROM MyTable
Less ideal:
SELECT case when example IS NULL then 1 else example end AS example FROM MyTable
Those are the basics. ISNULL() is much preferred unless there are more conditions to check in addition to NULL.
September 15, 2004 at 2:10 am
alternatively if you want to check for more than 1 value. You could use a CASE statement. Check BOL for the correct syntax.
-- Alex
September 15, 2004 at 9:44 am
You can use COALESCE function also..
Select COALESCE(fieldName, 1) from myTable
- Kamlesh
September 16, 2004 at 7:01 am
FYI, COALESCE is a simplyfied version/flavor of the CASE statement (for more info see BOL).
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply