Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Async Stored Procedure Call in T-SQL

How one can make an async call to a stored procedure from another one?

Assume I have two stored procedures, SP1 and SP2 (this is a long running stored procedure, takes much time to execute, and doesn't return any result).

The stored procedure SP1 is defined like this:

CREATE PROCEDURE SP1
AS
BEGIN

  --custom business logic

  --CALL to SP2, but async

  EXEC SP2

END

How could you make a non-blocking/async call to SP like the above in SQL Server 2008/2012?

like image 830
humblecoder Avatar asked Aug 26 '13 17:08

humblecoder


1 Answers

There was once I tried to achieve this by wrapping the stored procedure into Job, and then Calling the job in the procedure through sp_start_job system sp.

EXEC dbo.sp_start_job N'Job name' ;
like image 179
Sonam Avatar answered Nov 15 '22 11:11

Sonam