Thursday
Jan072010
Odd SQL 2005/2008 Query Behaviour
Thursday, January 7, 2010 at 12:05PM 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

