(somewhat) Social
« ourSSD 1 - Is My Node Up? | Main | SQL Monitoring On The Cheap »
Thursday
Jan072010

Odd SQL 2005/2008 Query Behaviour

This is just strange….

If a column appears twice in your query and you attempt to use it within an order by statement you get an error, unless you fully qualify the column. This doesn’t happen in 2000, but does in 2005 & 2008

This doesn’t work:

select name, * from sysobjects
order by name

Msg 209, Level 16, State 1, Line 3
Ambiguous column name 'name'.


This does:

select name, * from sysobjects s

order by s.name

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>