tags:

views:

444

answers:

3

Hi, I am new to t-sql. Can someone tell me how to fetch records from a sql table in the same order WITHOUT using the order by clause?

+4  A: 

If you are using SQL Server (since you mention T-SQL), you may have some amount of luck by defining a clustered index on the table, which forces a storage ordering on the rows within the table. However, if you do not specify an order by clause, adding or removing joins or where clause conditions may cause that order to change because the optimizer may choose not to use that clustered index.

Jeffrey Hantin
+12  A: 

That can't be done. You might get lucky sometimes but you can't depend on it.

Mark Harrison
A: 

If you have a clustered index defined which controls the sequencing/order, you can use index hints within the select.

SAMills