I Have a query with Joins as 5 table. I get the result of this query approx 180 records. I want to know how is order by working in this case where no order by clause is used in my query. Cheers Varun Singh
If I understand the question correctly, you want to know how the data is ordered if you don't specifcy an ORDER BY clause.
It just depends on how SQL Server accesses the data, operations within the query, and the indexes involved. Any number of things affect it. Assume for a moment that it needs to perform a merge operation, which requires ordered data, but it's retreiving the data from an unordered source like a table scan, then the query itself will apply an ORDER BY clause, changing the order of the data. That's just one thin example. There is no way to know or ensure that the data will come back in any particular order except by including an ORDER BY clause.
answered May 03, 2010 at 11:45 AM
Grant Fritchey ♦♦