It seems every 3 years or so I need to be slapped upside the head and reminded that in SQL Server...record order in a result set is not guaranteed unless you use ORDER BY
So I don't have to be hit in the head again, I'm writing it down.
The issue is that:
frequently the results ARE returned in order of entry
frequently developers start assuming that will always be the case
frequently developers build code based on that assumption.
Months go by.
Then a subtle bug occasionally appears and someone spends the better part of an evening trying to replicate the bug, and finally generates mostly, but not entirely correct results. By all appearances nothing is missing, but the code is angry when prodded just so. Running the underlying stored procedure in Query Analyzer reveals that the records being returned are slightly out of order. The relevant SELECT statement lacks an ORDER BY clause. The clause is added. The records are returned in the expected order. The code is happy. The developer can go to sleep.