Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to have jobs with a null stop date?

Tags:

sql

sql-server

I had used the following SQL to list out all jobs without a stop date. I thought that I could use this to find all active jobs. What I noticed is that I have a number of jobs in this table with a null stop_execution_date. Some identical jobs (same job_id) are repeated multiple times in this table.

select job.*, activity.*
from msdb.dbo.sysjobs_view job
inner join msdb.dbo.sysjobactivity activity
on (job.job_id = activity.job_id)
where run_Requested_date is not null and stop_execution_date is null

When I run EXEC msdb.dbo.sp_help_job on these jobs, I see that they the current execution status is idle.

What do these jobs represent? Is this the behavior when the jobs are not killed properly?

like image 267
stevebot Avatar asked Oct 23 '12 19:10

stevebot


1 Answers

Each time the SQL Agent starts, it puts a new row in syssessions and subsequently any jobs run will get that session_id in sysjobactivity. For your jobs that have a null stop date, my guess is that they're not for the "current" session which would mean that they were still running when the agent was stopped.

like image 170
Ben Thul Avatar answered Nov 02 '22 11:11

Ben Thul