SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Default order if order by values are all equal
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

britanb
Starting Member

Philippines
2 Posts

Posted - 06/06/2012 :  05:38:15  Show Profile  Reply with Quote
Hi,

I am wondering what is the default order if all of the columns in the order by has the same value? How does SQL treat them?

Thanks

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 06/06/2012 :  06:09:16  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Unpredictable. Depends on how the query is executed and the storage chain. The order can change at any time.
In general if an index is used the rows will be returned in order of that index but parallelism and joins can affect that.

Same as if you don't have an order by clause.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Edited by - nigelrivett on 06/06/2012 06:09:46
Go to Top of Page

britanb
Starting Member

Philippines
2 Posts

Posted - 06/06/2012 :  08:00:46  Show Profile  Reply with Quote
Thanks nigelrivett. This helped cleared up some things.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000