Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Check SQL Agent Job Status

By MyDoggieJessie,

These functions are especially useful when you have to check the status of the agent jobs running across multiple servers (they will all have different GUIDS).

The first function looks up the agent job id from the sysjobs table. The second function looks up the job status from the sysjobactivity table and returns either one of the following 7 results:

0 - Not executing
1 - Current executing
2 - Waiting for thread
3 - Between retries
4 - Faileure during last run
5 - Suspended
6 - (not used)
7 - Performing completion actions
NULL - Job does not exists

So by easily passing in an agent job name, you can get the current executing status on any given server.

Total article views: 1987 | Views in the last 30 days: 2
 
Related Articles
FORUM

Executing status on SQL Server Agent Jobs

Jobs with Executing Status but not process the Jobs on SQL Server 2005 Agent

FORUM

How to check Snapshot agent status

How to check Snapshot agent status

FORUM

get status of running agent from the system at runtime

how to display ececution status of agent in windows application

FORUM

Executing SQL Agent Job Remotely

Executing SQL Agent Job Remotely

ARTICLE

TSQL function to detect SQL Agent job state

This article has a T-SQL function to detect the SQL Agent job state.

Tags
agent    
job    
status    
 
Contribute