I need to execute one procedure from another in background\asynchronously.
procedure1:
CREATE PROCEDURE procedure1
WITH EXECUTE AS OWNER
AS
BEGIN
//something happens here
EXEC procedure2
//something happens here
END
procedure2:
CREATE PROCEDURE procedure2
WITH EXECUTE AS OWNER
AS
BEGIN
WAITFOR DELAY '00:02'
END
I need procedure1 to execute without waiting for procedure2 to end. I've read this answer in other post:
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' ;
but I don't understand it. Can anyone explain it to me, please? Cause it doesn't look like something advanced but I cannot achieve what I want.