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,134 of 19,505   
   Erland Sommarskog to Erland Sommarskog   
   Re: CASE issue   
   28 Nov 14 22:47:47   
   
   From: esquel@sommarskog.se   
      
   Erland Sommarskog (esquel@sommarskog.se) writes:   
   > Indeed. Books Online leaves no doubt that it works like twenty-six   
   > expected. I need to discuss this with Microsoft. Will first have to   
   > check older versions.   
      
   It seems like in SQL 6.5 it works like described in Books Online. SQL 2000   
   works like later versions as does SQL 7. Although, note that there are   
   two patterns here: newid() and a subquery like in:   
      
    select   
      case  (SELECT a FROM bluddrig)   
            when 1  then 'Jan'   
            when 2  then 'Feb'   
            when 3  then 'Mar'   
            when 4  then 'Apr'   
            when 5  then 'May'   
            when 6  then 'Jun'   
            when 7  then 'Jul'   
            when 8  then 'Aug'   
            when 9  then 'Sep'   
            when 10 then 'Oct'   
            when 11 then 'Nov'   
            when 12 then 'Dec'   
            when 13 then 'was 13!'   
            when 0 then 'was 0!'   
            else 'Unknown'   
      end   
        from sysobjects   
      
      
   newid() is overall special, since it's reevaluated for every row, while   
   other built-in functions are evaluated once - at least as they only appear   
   once.   
      
   There is no newid() on SQL 6.5, so I can say what happens there. But on SQL   
   7 and later, the query with the subquery, has 14 access to the table   
   bluddrig - SQL 6.5 has one.   
      
   I have not gotten any response, but the likelihood that Microsoft would   
   accept this as a regression from 6.5 and change it is minimal. Not the   
   least since there is a possible backwards compatibility here.   
      
   So I have filed a doc bug:   
   https://connect.microsoft.com/SQLServer/feedback/details/1042044   
      
      
      
   --   
   Erland Sommarskog, Stockholm, esquel@sommarskog.se   
      
   --- 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