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.
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)?
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.
- Google: “what is the default ordering of rows returned from a select query?”
- Google: “sql server query natural sort without order site:stackoverflow.com”
Page no longer exists. See in in the Web Archive’s Wayback Machine: