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,126 of 19,505   
   bradbury9 to All   
   Re: CASE issue   
   24 Nov 14 04:16:04   
   
   From: ray.bradbury9@gmail.com   
      
   El lunes, 24 de noviembre de 2014 12:26:31 UTC+1, Erland Sommarskog  escribió:   
   > twenty-six 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.   
   >    
   > Set up a mapping table instead.   
   >    
      
   In the MSDN doc it does not mention anything about being a shortcut, and I   
   supposed it was not the case. Good to know that to avoid future errors.   
      
   > --    
   > Erland Sommarskog, SQL Server MVP   
   >    
   > 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