Result set changes unpredictably

Symptom

You run a query and the result set you expect changes each time you run it.

Explanation

Carefully review the result set you are getting. Are the results in the set truly different? Or are they simply being returned in the most efficient order each time. The order selected can change each time you execute the query, depending on when you last accessed the row and other factors.

Recommendation

If your result set must be returned in a predictable or consistent order, ensure that the SELECT statement includes an ORDER BY clause. If the result set is still returning results incorrectly, your database may be corrupt.

See also