Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SELECT statement

Author  Topic 

johny_eu
Starting Member

12 Posts

Posted - 2010-08-22 : 10:51:54
Hello,

in which order should SELECT return the results if there's no ORDER BY statement? Does CLUSTERED INDEX has any affect on it? Has it affect when CLUSTERED INDEX in on IDENTITY PRIMARY KEY and when CLUSTERED INDEX in on another column in table?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-22 : 11:07:54
No. There are never such guarantees. If it looks like the records come back in same order as the clustered index, it is just by coincidense.
The ONLY sure way to guarantee the order of records is to use ORDER BY in the last/outermost SELECT statement.

There are many thing affecting the order of returned records, parallellism being the most prominent.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -