Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #1842
| Newsgroups | comp.databases.ms-sqlserver |
|---|---|
| Date | 2014-11-24 04:16 -0800 |
| References | <547306f8$0$41749$c3e8da3$5d8fb80f@news.astraweb.com> <XnsA3EF7E8B63B6CYazorman@127.0.0.1> |
| Message-ID | <3fc10276-8769-4885-ad67-1a5aee9dbb5c@googlegroups.com> (permalink) |
| Subject | Re: CASE issue |
| From | bradbury9 <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
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
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