Wednesday, March 28, 2012

Job Status Suspended

i am trying to code a proc that tests whether a job is running. i
understand how to get job status from the xp_sqlagent_enum_jobs via the
current execution status and i also understand that status = 4 means
the job is idle. what does status =5 (suspended) mean? The BOL
information seems to indicate that the job isnt running when status is
either 4 or 5 (status 0 = not idle and not suspended)
thanks
markHow about this bit of TSQL
select step_id FROM
msdb.dbo.sysjobhistory
WHERE instance_id =
(SELECT max(instance_id) FROM msdb.dbo.sysjobhistory h
INNER JOIN msdb.dbo.sysjobs j ON h.job_id=j.job_id
WHERE j.[name] = 'Your Job Name')
This will extract the current step that a job is on. If a has completed, the
step_id will be zero. If it hasn't completed, the step_id will be non-zero.
"markfcook@.gmail.com" wrote:

> i am trying to code a proc that tests whether a job is running. i
> understand how to get job status from the xp_sqlagent_enum_jobs via the
> current execution status and i also understand that status = 4 means
> the job is idle. what does status =5 (suspended) mean? The BOL
> information seems to indicate that the job isnt running when status is
> either 4 or 5 (status 0 = not idle and not suspended)
> thanks
> mark
>

No comments:

Post a Comment