DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to check the status of a job?

Execute the following Microsoft SQL Server T-SQL script in SSMS Query Editor to check job status & all job information, running status and start a job programmatically :

-- SQL Server check job status with all job related information

USE msdb

EXEC dbo.sp_help_job @job_name = N'Inventory DB Backup',

                               @job_aspect = N'ALL' ;

GO

 

-- Check run status of a job - check if job currently running

-- SQL Server Agent - Running = 1 means currently executing

DECLARE @job_id uniqueidentifier

SELECT @job_id=job_id FROM msdb.dbo.sysjobs WHERE name=N'Inventory DB Backup'

-- SET @job_id = '4C004358-62E0-4933-9268-90F54EF36AA9' 

EXEC master.dbo.xp_sqlagent_enum_jobs 1, sa, @job_id

GO

 

-- SQL Server start job programmatically

EXEC msdb.dbo.sp_start_job N'Inventory DB Backup';

GO

Related articles:

http://www.sqlusa.com/bestpractices2005/startjobfromstoredproc/

Detecting The State of a SQL Server Agent Job - How to Find SQL Server Job Execution Status - Using xp_sqlagent_enum_jobs - Retrieve Job status for running job

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE