Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kathyc2003
Starting Member
15 Posts |
Posted - 2006-12-04 : 16:14:23
|
HelloI have written a case statement and it does the exact opposite of what I want it to do. If the field New_sales_initiative is NULL, it puts in a valueof 'I AM NOT NULL' and vice versa.What have I done wrong?SELECT createdbyname, New_sales_initiative, leadsourcecodename, CASE New_sales_initiative WHEN NULL THEN 'I AM NULL' ELSE 'I AM NOT NULL' END AS impied_sales_initiativeFROM dbo.FilteredLead |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-04 : 16:20:39
|
[code]SELECT createdbyname,New_sales_initiative,leadsourcecodename,CASE WHEN New_sales_initiative IS NULLTHEN 'I AM NULL'ELSE 'I AM NOT NULL'END AS impied_sales_initiativeFROM dbo.FilteredLead[/code]Also, check out the ISNULL and COALESCE functions for checking for NULLs. |
 |
|
kadams21
Starting Member
3 Posts |
Posted - 2006-12-04 : 16:24:04
|
Give this a shot...SELECTcreatedbyname,New_sales_initiative,leadsourcecodename,impied_sales_initiative = CASE WHEN New_sales_initiative IS NULL THEN 'I AM NULL' ELSE 'I AM NOT NULL' ENDFROM dbo.FilteredLead |
 |
|
|
|
|