Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 1876 | Views in the last 30 days: 6
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones