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
2009-01-18 03:59:01
+12
A:
That can't be done. You might get lucky sometimes but you can't depend on it.
Mark Harrison
2009-01-18 04:08:21
A:
If you have a clustered index defined which controls the sequencing/order, you can use index hints within the select.
SAMills
2009-01-20 22:26:02