Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 R2 stored procedure output results in different order when executing multiple times

Just encountered an odd behavior during our regression with a stored procedure which output thousands of records:

The stored procedure could output the results in different orders with same parameters if it's being called more than 20 times in a short while.

Anyone got any idea about this behavior?

For some reason, we are not able to specify the order explicitly in the stored procedure.

like image 604
Rex Avatar asked Dec 31 '25 04:12

Rex


1 Answers

A parallel query plan sounds a likely culprit ( or different query plans being used on different runs).

If you are not explicitly ordering with an ORDER BY, then no order is guaranteed.

Can you post the Stored Procedure and a query plan?

like image 191
Mitch Wheat Avatar answered Jan 02 '26 19:01

Mitch Wheat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!