home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,066 of 19,505   
   Erland Sommarskog to tshad   
   Re: Case with NULL   
   13 Jan 11 08:49:42   
   
   From: esquel@sommarskog.se   
      
   tshad (tfs@dslextreme.com) writes:   
   > Why can I do:   
   > SELECT PersonID = CASE o.ID WHEN NULL THEN o2.ID ELSE o.ID END   
      
   Just because you can, does not mean that you should. This experssion   
   will always return o.ID, because comparisons will NULL always yield   
   UNKNOWN.   
      
   You should write this as   
      
      CASE WHEN o.ID IS NULL THEN o2.ID ELSE o.ID END   
      
      
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Books Online for SQL Server 2005 at   
   http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx   
   Books Online for SQL Server 2000 at   
   http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca