Hello Running SQL Server version Microsoft SQL Server 2017 14.0.3281.6 (X64)
I have a query which when run in SSMS finishes exactly when I want it to, what it does it goes to a different server and checks if a job has completed ether successfully or unsuccessfully - basically I just want to know when it finishes.
select * from XXXX.msdb.dbo.sysjobhistory jh
join XXXX.msdb.dbo.sysjobs_view jv on jh.job_id = jv.job_id
where jv.name = 'XXXX'
and jh.step_name = '(job outcome)'
and run_date = cast(datepart(YY, getdate()) as varchar(4)) +
right('0' + cast(datepart(MM, getdate()) as varchar(3)), 2) +
right('0' + cast(datepart(DD, getdate()) as varchar(3)), 2))
BEGIN
WAITFOR DELAY '00:00:15'
END
I just want to stress again in SSMS it completes as expected.
I then put the code as step one in a job, with all the correct things such as on completion go to next step on error - error and so on. The problem is that step itself never completes.
Could someone in the community please tell me what the issue is ? This being a fairly new install of SQL Server I think there maybe a config option I need to choose.
Thanks for Reading
Peter