Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How can I check SQL Agent Job current status ?

13 October,2022 by Tom Collins

Question: How can I check the current SQL Server Agent Job Status?

Answer:  You have a few different options to check the SQL Server Agent Jobs Status.

Option 1 : SQL Server Job Activity Monitor .Check the "Status" 

Option 2 : Use the syshobhistory  run_status column - Check SQL Agent Job Exceution Status and Messages Generated with a sql script

Option 3 :    SQL-DMO , reading the output from the CurrentRunStatus Property
The CurrentRunStatus property returns the executing state of a SQL Server Agent job.

If you're using  the SQL-DMO method - the see the latest status you'll need to apply Refresh method.

Here is a short code snippet in Powershell.if you want to monitor this over a period of time you'll need to apply some extra logic - such as a while .. loop with a sleep step

$jobStatus = $job.CurrentRunStatus

$job.Refresh() #refresh the job connection
$jobStatus = $job.CurrentRunStatus #s status

 

 

 

SQLDMOJobExecution_BetweenRetries 3 Job is waiting on a job step retry attempt.
SQLDMOJobExecution_Executing 1 Job is executing.
SQLDMOJobExecution_Idle 4 Job is idle, awaiting its next scheduled execution.
SQLDMOJobExecution_PerformingCompletionActions 7 All executable job steps complete. Job history logging in progress.
SQLDMOJobExecution_Suspended 5 Job is suspended.
SQLDMOJobExecution_Unknown 0 State cannot be determined.
SQLDMOJobExecution_WaitingForStepToFinish 6 Job is waiting on the outcome of a step.
SQLDMOJobExecution_WaitingForWorkerThread 2 Job is blocked, unable to obtain a thread resource.

 

 

Read More on SQL Agent 

List enabled status of SQL Server Agent Jobs

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How can I check SQL Agent Job current status ?


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer