Default/natural sort order of rows returned from SQL SELECT query without an ORDER BY clause

This is mainly a reference post for myself as it took a few tries to get correct Google queries to find the answers I’m after.

Question:

What is the natural/default sort order records will be returned from a query on a SQL Server table that does not specify an explicit sort order?

Answer:

 There is no guarantee of the sort order.
Often it will return records in the order you inserted them, sometimes it won’t.
If you want to guarantee an order to the returned records, provide an ORDER BY clause in the query.

Resources:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>