sql server 2008 r2 - SQL Different output result set for same query -
why sql query produces different output result in sql 2008r2 , 2012.it seems 2008r2 results query looks fine.why same sort order missing in 2012?
declare @temptable table (name varchar(25), rankorder int) insert @temptable select 'b', 2 union select 'd', 4 union select 'a', 1 union select 'e', 5 union select 'c', 3 select * #resulttable @temptable order rankorder select * #resulttable drop table #resulttable
using select ... <new_table> ...
statement pretty ignores order by
statement.
from into clause documentation, limitations , restrictions:
specifying order clause not guarantee rows inserted in specified order.
you select
rows temporary table without order by
clause, gives no guarantees order receive rows in. assume same order rows inserted, there no guarantee order either.
in conclusion cannot expect specific order in rows returned, , may differ in different versions of same rdbms.
Comments
Post a Comment