Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!Xl.tags.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.powerusenet.com!news.powerusenet.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 28 Nov 2014 19:19:22 -0600 From: Jim Newsgroups: comp.databases.ms-sqlserver Subject: Re: CASE issue Date: Fri, 28 Nov 2014 17:19:34 -0800 Message-ID: References: <547306f8$0$41749$c3e8da3$5d8fb80f@news.astraweb.com> <3fc10276-8769-4885-ad67-1a5aee9dbb5c@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit User-Agent: MicroPlanet-Gravity/3.0.4 Lines: 49 X-Trace: sv3-b4zVMLQqc3LAcrJHWsncGbp2M4/OfAjMNBiupZtUgbkbXYU06LvU55LrqkzR+Q356AZ/v442oPSTAjF!VB20bxoeNimKfWMvguxea4RUOAiidHh2bePdkKg/e/fRp51sLsi7W+tvlPhs3rykAiyPKoVz/6lH!ekbX9DkN16Njng== X-Complaints-To: www.powerusenet.com/docs/dmca.html X-DMCA-Complaints-To: www.powerusenet.com/docs/abuse.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2984 Xref: csiph.com comp.databases.ms-sqlserver:1852 In article , esquel@sommarskog.se says... > > 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 Very good.