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 19,131 of 19,505   
   Lennart Jonsson to Erland Sommarskog   
   Re: CASE issue   
   24 Nov 14 17:18:43   
   
   From: erik.lennart.jonsson@gmail.com   
      
   On 11/24/2014 12:26 PM, Erland Sommarskog wrote:   
   > twenty-six@b-mint.net (twenty-six@b-mint.net) writes:   
   >> When I run this query I get lots of 'Unknown'  values, but I'm not sure   
   >> why.   
   >   
   > This happens because   
   >   
   >      CASE expr WHEN val1 THEN ....   
   >                WHEN val2 THEN ....   
   >   
   > is a shortcut for   
   >   
   >     CASE WHEN expr = val1 THEN   
   >          WHEN expr = val2 THEN   
   >   
   > and thus the expression gets evaluated multiple times and then it goes   
   > downhill from there.   
   >   
      
   I think (don't have time to look it up now) the SQL-standard says that   
   the result of the CASE statement is the first condition that evaluates   
   to true. From your answer I get the impression that this is not true for   
   SQL-server, correct?   
      
   Surely only one value is returned, but is it indeterministic which one?   
      
      
   /Lennart   
      
   [...]   
      
   --- 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