x

How is table output done in joins table where no ORDER BY is specified

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

more ▼

asked May 03, 2010 at 11:39 AM in Default

avatar image

Techno
34 3 3 5

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

If I understand the question correctly, you want to know how the data is ordered if you don't specifcy an ORDER BY clause.

Basically, randomly.

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.

more ▼

answered May 03, 2010 at 11:45 AM

avatar image

Grant Fritchey ♦♦
137k 20 44 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x162
x28

asked: May 03, 2010 at 11:39 AM

Seen: 768 times

Last Updated: May 03, 2010 at 11:49 AM

Copyright 2017 Redgate Software. Privacy Policy