Hello Experts;
I have a stored procedure which is used to run a job. However, within my stored procedure I have an sql query which is used to get the status of the job, how can I make sure the job is completed first before the sql statement is ran. My code is structured as the following below
create procedure dbo.sprun_job(@info_p varchar(45) out)
with execute as a caller
as execute as login = N'testuser'exec msdb.dbo.msdbsprun_job
revert;waitfor delay '00:00:30';
set @info_p = (select run_status from msdb.dbo.sysjobhistory b)
if the waitfor delay is not there, it will say the job is still running, hence i want to make sure they job is done running before the run_status gets stored in info_p
How do I ensure that?
Thanks in advance