quarks
quarks

Reputation: 35316

List all the jobs that have been executed within a specified date?

Is is possible to list all the scheduled jobs that have been executed for a specified date? I'm having a problem where I am not sure if the job has executed yesterday and if all the steps where executed as well?

Upvotes: 1

Views: 739

Answers (2)

naik
naik

Reputation: 1

find in this below link it gives all the information about sql jobs

http://www.mssqltips.com/sqlservertip/2561/querying-sql-server-agent-job-information/

Upvotes: 0

Serge Belov
Serge Belov

Reputation: 5803

To list all the jobs that started within a specified date:

declare @date date = getdate()

SELECT
    J.job_id,
    J.name
FROM msdb.dbo.sysjobs AS J 
INNER JOIN msdb.dbo.sysjobhistory AS H ON H.job_id = J.job_id
WHERE run_date = CONVERT(VARCHAR(8), GETDATE(), 112)
GROUP BY J.job_id, J.name

To list all the steps for a specified job on a specified date with their status:

declare @date date = getdate()
declare @job_name varchar(50) = 'test'

SELECT
    H.run_date,
    H.run_time,
    H.step_id,
    H.step_name,
    H.run_status
FROM msdb.dbo.sysjobs AS J
INNER JOIN msdb.dbo.sysjobhistory AS H ON H.job_id = J.job_id
WHERE 
    run_date = CONVERT(VARCHAR(8), GETDATE(), 112)
    AND J.name = @job_name

More information here.

Upvotes: 2

Related Questions