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,063 of 19,505   
   tshad to All   
   Case with NULL   
   12 Jan 11 19:12:07   
   
   From: tfs@dslextreme.com   
      
   Why can I do:   
      
   SELECT PersonID = CASE WHEN o.ID  IS NULL THEN o2.ID ELSE o.ID END   
      
   SELECT PersonID = CASE WHEN o.ID IS NOT NULL THEN o2.ID ELSE o.ID END   
      
   SELECT PersonID = CASE o.ID WHEN NULL THEN o2.ID ELSE o.ID END   
      
   But not:   
      
   SELECT PersonID = CASE o.ID WHEN NOT NULL THEN o2.ID ELSE o.ID END   
      
   I get an error:   
      
          Incorrect syntax near the keyword 'NOT'.   
      
   and   
      
   SELECT PersonID = CASE o.ID WHEN IS NOT NULL THEN o2.ID ELSE o.ID END   
      
   I get an error:   
      
          Incorrect syntax near the keyword 'IS'.   
      
   Using this syntax, can I not test for 'NOT NULL'?   
      
   Thanks,   
      
   Tom   
      
   --- 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