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 of records returned from a query on a SQL Server table (where an ORDER BY is not explicitly specified)?

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 for 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>

This site uses Akismet to reduce spam. Learn how your comment data is processed.