Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: CASE issue Date: Sat, 29 Nov 2014 10:43:01 +0100 Organization: Erland Sommarskog Lines: 17 Message-ID: References: <547306f8$0$41749$c3e8da3$5d8fb80f@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="416ef8a880b1e4f6f96e9a7c39a8d7a9"; logging-data="18460"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+f3/FEodRxIy+f2HNpaNDc" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:OZUA8TTjqotgUvALeIZqoD6sffE= Xref: csiph.com comp.databases.ms-sqlserver:1853 Jim (jgeissman@socal.rr.com) writes: > 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. > I don't think that would work well, because you want a new random number per row. You could use a column on the row as seed - but then it would be deterministic. Look at this. SELECT rand(), rand(object_id) FROM sys.objects -- Erland Sommarskog, Stockholm, esquel@sommarskog.se