I am actually working on SP in SQL 2005. Using SP i am creating a job and am scheduling it for a particular time. These jobs take atleast 5 to 10 min to complete as the database is very huge. But I am not aware of how to check the status of the Job. I want to know if it has got completed successfully or was there any error in execution. On exception i also return proper error code. But i am not aware of where i can check for this error code.
This is what I could find, maybe it solves your problem:
exec msdb.dbo.sp_help_jobactivity @job_id = (your job_id here)
You can execute this SP and place the result in a temp table and get the required result from there.
Otherwise have a look at these tables:
msdb.dbo.sysjobactivity
msdb.dbo.sysjobhistory
Run the following to see the association between these tables.
exec sp_helptext sp_help_jobactivity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With