Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #1149
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming |
| Subject | Re: Puzzling ORDER BY |
| Followup-To | comp.databases.ms-sqlserver |
| Date | 2012-06-22 11:31 +0200 |
| Organization | Erland Sommarskog |
| Message-ID | <XnsA07A752DCF965Yazorman@127.0.0.1> (permalink) |
| References | <t5j6u7l37h8sn1qieugouq6k0v78kbtbv0@4ax.com> <4fe3713b$0$6908$e4fe514c@news2.news.xs4all.nl> <bd17u7lv72v3aud4hefa4bmp437t90svmv@4ax.com> <4fe40fa8$0$6962$e4fe514c@news2.news.xs4all.nl> |
Cross-posted to 2 groups.
Followups directed to: comp.databases.ms-sqlserver
Jeroen Mostert (jmostert@xs4all.nl) writes: > Yes, you're right -- if you supply a constant expression explicitly, SQL > Server will catch this and flag it as nonsensical. A bit overzealous, I > think. It's mostly harmless, compared to other things that aren't > detected. > > If you use "NULL + [column]", or any other expression that always yields > NULL but isn't constant, the error goes away. The CASE, of course, is > not a constant expression. Or you can say ORDER BY (SELECT NULL). Which is not very useful in the main ORDER BY for a query, but this is useful with row_number() when you don't care about the order. (ORDER BY is mandatory for row_number.) -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
Puzzling ORDER BY Gene Wirchenko <genew@ocis.net> - 2012-06-21 09:37 -0700
Re: Puzzling ORDER BY Jeroen Mostert <jmostert@xs4all.nl> - 2012-06-21 21:08 +0200
Re: Puzzling ORDER BY Gene Wirchenko <genew@ocis.net> - 2012-06-21 13:40 -0700
Re: Puzzling ORDER BY Jeroen Mostert <jmostert@xs4all.nl> - 2012-06-22 08:24 +0200
Re: Puzzling ORDER BY Erland Sommarskog <esquel@sommarskog.se> - 2012-06-22 11:31 +0200
Re: Puzzling ORDER BY Erland Sommarskog <esquel@sommarskog.se> - 2012-06-21 23:31 +0200
Re: Puzzling ORDER BY Jeroen Mostert <jmostert@xs4all.nl> - 2012-06-22 08:46 +0200
Re: Puzzling ORDER BY rja.carnegie@gmail.com - 2012-07-02 03:36 -0700
csiph-web