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,076 of 19,505   
   Gene Wirchenko to esquel@sommarskog.se   
   Re: Case with NULL   
   16 Jan 11 20:10:20   
   
   From: genew@ocis.net   
      
   On Fri, 14 Jan 2011 23:13:32 +0100, Erland Sommarskog   
    wrote:   
      
   >Gene Wirchenko (genew@ocis.net) writes:   
   >>      Not the adjective I would have picked.   
   >   
   >You're not Swedish, are you? :-)   
      
       No, why?   
      
   >> Is there a technical difference that matters?   
   >   
   >Well, it was the one I used:   
   >   
   >>>Say that you write:   
   >>>   
   >>>  coalesce((SELECT ....), 4711)   
   >>>   
   >>>Looks good. But this is the true story:   
   >>>   
   >>>   CASE WHEN (SELECT ...) IS NOT NULL THEN (SELECT ...) ELSE 4711 END   
   >>>   
   >>>Personally, I use coalesce all the time.   
   >   
   >When you use CASE, you easier realise that the subquery is computed   
   >twice.   
      
        And only once with coalesce() which would argue in favour of   
   using it.  (Naturally, all bets are off when optimisation enters the   
   picture.)   
      
   Sincerely,   
      
   Gene Wirchenko   
      
   --- 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