You can use these two SPS to quickly view the status of a job execution without opening monitory.
1. View Job Execution Results
exec [msdb]. [dbo]. [sp_help_job]
The parameters for this dbo.sp_help_job in msdb are as follows:
ALTER PROCEDURE [dbo].[sp_help_job] --Individual Job Parameters @job_id uniqueidentifier = NULL,--If provided should not also provide job_name @job_namesysname= NULL,--If provided should not also provide job_id @job_aspect VARCHAR(9)= NULL,--JOB, STEPS, schedules, TARGETS or all --Job Set Parameters @job_type VARCHAR( A)= NULL,--LOCAL or Multi-Server @owner_login_namesysname= NULL, @subsystem NVARCHAR( +)= NULL, @category_namesysname= NULL, @enabled TINYINT = NULL, @execution_status INT = NULL,--1 = executing, 2 = Waiting for Thread, 3 = between retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 = PERFORMINGC Ompletionactions @date_comparator CHAR(1)= NULL,--< or = @date_created DATETIME = NULL, @date_last_modified DATETIME = NULL, @description NVARCHAR( +)= NULL --We do a like on the so it can include wildcards as
2. View Job Step
Declare @tmp_sp_help_jobhistory Table(instance_idint NULL, job_iduniqueidentifier NULL, job_name sysnameNULL, step_idint NULL, step_name sysnameNULL, sql_message_idint NULL, Sql_severityint NULL, Messagenvarchar(4000)NULL, Run_statusint NULL, Run_dateint NULL, Run_timeint NULL, Run_durationint NULL, operator_emailed sysnameNULL, operator_netsent sysnameNULL, operator_paged sysnameNULL, retries_attemptedint NULL, server sysnameNULL )Insert into @tmp_sp_help_jobhistory execmsdb.dbo.sp_help_jobhistory@job_id = 'af5eb80e-ef1e-4f2c-adb3-a45bfc2c3f57', @mode=' Full' SELECTtshj.instance_id as [InstanceID], tshj.sql_message_id as [SQLMessageID], Tshj.message as [Message], tshj.step_id as [StepID], Tshj.step_name as [Stepname], Tshj.sql_severity as [sqlseverity], tshj.job_id as [JobID], Tshj.job_name as [JobName], Tshj.run_status as [Runstatus], CaseTshj.run_date when 0 Then NULL ELSE Convert(datetime, Stuff(Stuff(cast(tshj.run_date as nchar(8)),7,0,'-'),5,0,'-')+N' ' + Stuff(Stuff(substring(cast(1000000 +Tshj.run_time as nchar(7)),2,6),5,0,':'),3,0,':'), -)END as [rundate], Tshj.run_duration as [runduration], tshj.operator_emailed as [operatoremailed], Tshj.operator_netsent as [operatornetsent], tshj.operator_paged as [operatorpaged], tshj.retries_attempted as [retriesattempted], Tshj.server as [Server], getdate() as [currentdate] from @tmp_sp_help_jobhistory asTshjORDER by [InstanceID] ASC
The parameters for Dbo.sp_help_jobhistory in msdb are as follows:
ALTER PROCEDURE [dbo].[sp_help_jobhistory] @job_id uniqueidentifier = NULL, @job_namesysname= NULL, @step_id INT = NULL, @sql_message_id INT = NULL, @sql_severity INT = NULL, @start_run_date INT = NULL,--YYYYMMDD @end_run_date INT = NULL,--YYYYMMDD @start_run_time INT = NULL,--HHMMSS @end_run_time INT = NULL,--HHMMSS @minimum_run_duration INT = NULL,--HHMMSS @run_status INT = NULL,--sqlagent_exec_x Code @minimum_retries INT = NULL, @oldest_first INT = 0,--Or 1 @serversysname= NULL, @mode VARCHAR(7)= 'SUMMARY' --or ' full ' or ' SEM '
Agent history5:job Activity Monitor to view the Job history code