From: tfs@dslextreme.com   
      
   "Lennart Jonsson" wrote in message   
   news:igmca7$b1b$1@news.eternal-september.org...   
   > On 2011-01-13 04:12, tshad wrote:   
   > [...]   
   >>   
   >> SELECT PersonID = CASE o.ID WHEN NULL THEN o2.ID ELSE o.ID END   
   >   
   > I'm a bit surprised that this works. This case construction uses "=" and   
   > nothing (including null) equals null. FWIW, this should be equal to:   
   >   
   > SELECT coalesce(o.ID, o2.ID)   
      
   Is one better than the other?   
      
   SELECT PersonID = coalesce(o.ID, o2.ID)   
      
   or   
      
   SELECT PersonID = CASE WHEN o.ID IS NULL THEN o2.ID ELSE o.ID END   
      
   Thanks,   
      
   Tom   
      
   >   
   >>   
   >> 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   
   >>   
   >   
   > There is another CASE construction (my windows vm is down so I can't   
   > verify whether it is supported by sqlserver)   
   >   
   > CASE WHEN o.ID IS NOT NULL THEN o2.ID ELSE ...   
   >   
   >   
   > /Lennart   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|