Search code examples
sqlsql-serverdatabasedatabase-design

Does a SELECT query always return rows in the same order? Table with clustered index


Will my select * query always return the rows from my database table in the same order?

My table has a 'clustered index' on one column. Does that change the answer?


Solution

  • The order of the returned rows will not always be the same unless you explicitly state so with the ORDER BY clause. So, no.

    And no; just because your 1000 queries have returned the same order it's no guarantee the 1001th query will be in the same order.