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
 General SQL Server Forums
 New to SQL Server Programming
 PK Order

Author  Topic 

kumpikov
Starting Member

1 Post

Posted - 2008-06-10 : 13:48:33
I have a compiled and deployed to our clients site application, which in one case does not use ORDER BY clause in a sql statement. The assumption has been that SQL Server will always return the rows in ascending order of the PK (it is a composite PK). However, on some SQL Server machines the order is returned correctly, on others - not. I suspect that the order is defined by the way the indexing structure is built behind the scenes. The process of deploying patches to the clients' sites is difficult and very long. I am wondering if there is some SQL Server setting (stored procedure), which will rebuild the indexing structure in a way so that it uses the ascending order of the PK columns.

Thank you,
Nikolay

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-10 : 13:51:04
You can never guarantee the order of retrieval of records from a table unless you explicitly specifies the order by means of an ORDER BY clause.
Go to Top of Page
   

- Advertisement -