The EnumHistory method returns a QueryResults object enumerating the execution history of the referenced SQL Server Agent job.
object.EnumHistory( [ JobHistoryFilter ] ) as QueryResults
Part | Description |
---|---|
object | Expression that evaluates to an object in the Applies To list |
JobHistoryFilter | Optional. A JobHistoryFilter object restricting result set membership. |
A QueryResults object containing one result set defined by these columns.
Column | Data type | Description |
---|---|---|
instance_id | integer | System-generated identifier for execution attempt. |
job_id | uniqueidentifier | System-generated job identifier. |
job_name | nvarchar(129) | Job name. |
step_id | integer | User-specified step identifier. The result set lists each job step and its outcome. |
step_name | nvarchar(129) | Job step name. |
sql_message_id | integer | When applicable, the Microsoft® SQL Server™ message number of the message raised by the step. |
sql_severity | integer | When applicable, the severity of a SQL Server message raised by the step. |
message | nvarchar(1025) | When applicable, text of a SQL Server message raised by the step. |
run_status | integer | Execution outcome interpreted by using SQLDMO_JOBOUTCOME_ TYPE. |
run_date | integer | Date on which execution occurred formatted as described in Remarks. |
run_time | integer | Time at which execution occurred formatted as described in Remarks. |
run_duration | integer | Execution duration expressed as a number of seconds. |
operator_emailed | nvarchar(129) | When applicable, operator receiving e-mail notification of job completion. |
operator_netsent | nvarchar(129) | When applicable, operator receiving network popup message notification of job completion. |
operator_paged | nvarchar(129) | When applicable, operator receiving page notification of job completion. |
retries_attempted | integer | Number of times SQL Server Agent attempted execution of the step. 0 when the step executed successfully on the first attempt or no retry attempts specified for the job step. |
server | nvarchar(31) | Target server name. |
The result set column run_date represents the execution date as a scaled long integer. The integer is built as a sum of the year scaled by 10000, the month scaled by 100, and the day. For example, the date April 19, 1997 is represented by the long integer value 19970419.
The result set column run_time represents execution time as a scaled long integer. The integer is built as a sum of the hour scaled by 10000, the minute scaled by 100, and the seconds. The value uses a 24-hour clock. For example, the time 1:03:09 P.M. is represented by the long integer value 130309.
Membership in the result set is restricted by using the optionally specified JobHistoryFilter object. For more information, see JobHistoryFilter Object.
HRESULT EnumHistory(
LPSQLDMOQUERYRESULTS* ppResults,
LPSQLDMOJOBHISTORYFILTER pJobHistoryFilter = NULL);