Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1851

Re: CASE issue

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border1.nntp.dca1.giganews.com!Xl.tags.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!local2.nntp.dca.giganews.com!nntp.powerusenet.com!news.powerusenet.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 28 Nov 2014 18:06:53 -0600
From Jim <jgeissman@socal.rr.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: CASE issue
Date Fri, 28 Nov 2014 16:07:05 -0800
Message-ID <MPG.2ee2ae00cb38741598968b@news.powerusenet.com> (permalink)
References <547306f8$0$41749$c3e8da3$5d8fb80f@news.astraweb.com> <XnsA3EF7E8B63B6CYazorman@127.0.0.1> <m4vlom$q0c$1@dont-email.me> <XnsA3EFF04705958Yazorman@127.0.0.1> <m513rc$8vr$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
User-Agent MicroPlanet-Gravity/3.0.4
Lines 27
X-Trace sv3-LQrA8RJlNP0YdaC1hN6hKthG7SVSV5ZiEbV2SQmTH6tRFhVO5r8QDVIHiPMiNwQKYja6OqGEEyi0JFV!VdgJnoMcSDv1gt2AWaOsPTssZqpusO7YkibF1vcDo0w47bFiUiyGVga7OWabO05Th44x1BDHz5XV!BwC6Mf5Oa+MgmQ==
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 2180
Xref csiph.com comp.databases.ms-sqlserver:1851

Show key headers only | View raw


In article <m513rc$8vr$1@dont-email.me>, erik.lennart.jonsson@gmail.com 
says...
> 
> On 11/24/2014 11:37 PM, Erland Sommarskog wrote:
> > Lennart Jonsson (erik.lennart.jonsson@gmail.com) writes:
> >> 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?
> >
> > That is indeed true. The issue is that the expression on the left-hand side
> > is reevaluated for every branch in the CASE.
> >
> 
> I see, thanks
> 
> 
> /Lennart

I believe RAND() is evaluated once at the beginning, while NEWID() is 
evaluated each time. So one solution would be to evaluate the NEWID() 
version and park the result in a variable and use the variable, or use 
RAND() but base it on a seed that doesn't involve NEWID(), or at least 
if it does, determine it outside of the CASE statement.


Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 10:22 +0000
  Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 11:26 +0000
    Re: CASE issue bradbury9 <ray.bradbury9@gmail.com> - 2014-11-24 04:16 -0800
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 14:28 +0000
        Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-28 22:47 +0100
          Re: CASE issue Jim <jgeissman@socal.rr.com> - 2014-11-28 17:19 -0800
    Re: CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 13:32 +0000
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 14:25 +0000
        Re: CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 16:06 +0000
    Re: CASE issue Lennart Jonsson <erik.lennart.jonsson@gmail.com> - 2014-11-24 17:18 +0100
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 23:37 +0100
        Re: CASE issue Lennart Jonsson <erik.lennart.jonsson@gmail.com> - 2014-11-25 06:25 +0100
          Re: CASE issue Jim <jgeissman@socal.rr.com> - 2014-11-28 16:07 -0800
            Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-29 10:43 +0100

csiph-web