Sql does not have async or parallel support. The sp_executesql will send all its result rows to the client before the next statement.
Execution order in a stored procedure
Fredrik M
246
Reputation points
Hi,
Need some help.
Easy example. Lets say I have two store procedures, A and B, as below.
CREATE RPOCEDURE dbo.A
AS
BEGIN;
DECLARE @id int=1;
WHILE(@id <5);
BEGIN;
EXEC sp_executesql dbo.B @id=@id
SET @id=@id+1
END;
END;
I assume that the loop does not wait for procedure dbo.B to finish before it executes it again with the next parameter (@id=2), which means that it is paralell execution of the Procedure B?
Is there anyway I can accomplish that it executes sequential, meaning that the loop holds until procedure B finnished?
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,705 questions