Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default order in SELECT statement

Status
Not open for further replies.

antwerp

Programmer
Feb 23, 2001
2
US
In a select statement like the foll

SELECT ID FROM TABLE1 WHERE VALUE < 234

Let us assume that ID is the primary key and VALUE may or may not be a unique index.

Is there any database setting that can be changed, so that the above SELECT statment always returns ID in sorted order. I know that using ORDER BY clause would do the trick, but the situation is that we are not in a position to change the code that contains the SQL statement, but it would be OK to change any database setting to accomplish the same. Any help is highly appreciated
 

SQL Server 7 and 2000 do not guarantee that results sets will be ordered. (The ANSI standard does not provide for ordered results without an Order By clause.) However, it has been my experience that results sets without and Order By clause will be ordered in the sequence of the clustered index on the table.

The difficulty is that ID may be a poor choice for a clustered index and making it clustered could lead to performance problems. This is something you would need to experiment with. Terry Broadbent
Please review faq183-874.

&quot;The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge.&quot; - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top