Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Job Status

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.

like image 262
Vinod Avatar asked May 05 '26 09:05

Vinod


1 Answers

This is what I could find, maybe it solves your problem:

  1. SP to get the current job activiity.
 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

like image 82
Philip Fourie Avatar answered May 07 '26 22:05

Philip Fourie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!