Hi here is the script to find the SQL Server Job Execution information. This information can also be found in the Job History/Job Activity Monitor windows in SSMS.
1:
2:
3: SELECT [JobName] = JOB.name,
4: [Step] = HIST.step_id,
5: [StepName] = HIST.step_name,
6: [Message] = HIST.message,
7: [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
8: WHEN HIST.run_status = 1 THEN 'Succeeded'
9: WHEN HIST.run_status = 2 THEN 'Retry'
10: WHEN HIST.run_status = 3 THEN 'Canceled'
11: END,
12: [RunDate] = HIST.run_date,
13: [RunTime] = HIST.run_time,
14: [Duration] = HIST.run_duration
15: FROM msdb..sysjobs JOB
16: INNER JOIN msdb..sysjobhistory HIST ON HIST.job_id = JOB.job_id
17: WHERE HIST.run_date=convert(varchar,getdate(),112)
18: ORDER BY HIST.run_date, HIST.run_time
19:
20: /* WHERE JOB.name = '<job name>'
21: WHERE HIST.run_date='<yyyymmdd>' */
22:
23:

