patternModerate
Calling two stored procedures from one, is the order guaranteed?
Viewed 0 times
storedproceduresfromtheordertwoonecallingguaranteed
Problem
I have some code that looks like this:
Are the two datasets guaranteed to return in the called order? I am expecting two result sets to be passed back to my server code and am running into some issues and I feel the ordering may not be guaranteed. If it is not guaranteed, is there a way to enforce ordering?
Not the ordering of the data, but ordering of StoredProcedure1 always being returned as result set 1, and StoredProcedure2 always being returned as result set 2.
EXEC StoredProcedure1 @Arguments
EXEC StoredProcedure2 @ArgumentsAre the two datasets guaranteed to return in the called order? I am expecting two result sets to be passed back to my server code and am running into some issues and I feel the ordering may not be guaranteed. If it is not guaranteed, is there a way to enforce ordering?
Not the ordering of the data, but ordering of StoredProcedure1 always being returned as result set 1, and StoredProcedure2 always being returned as result set 2.
Solution
Yes. StoredProcedure1 will execute first, and any resultsets from StoredProcedure1 must be consumed by the client before StoredProcedure2 is executed.
It's possible that some client driver or DAL processes all the resultsets and then returns them to your calling code in a different order, but for SQL Server and the Microsoft client drivers, you will get the resultsets in the order in which they are produced.
It's possible that some client driver or DAL processes all the resultsets and then returns them to your calling code in a different order, but for SQL Server and the Microsoft client drivers, you will get the resultsets in the order in which they are produced.
Context
StackExchange Database Administrators Q#194397, answer score: 12
Revisions (0)
No revisions yet.