EnumJobs Method (SQL-DMO)

The EnumJobs method returns a QueryResults object enumerating all SQL Server Agent jobs defined for a server.

Applies To

JobServer Object

Syntax

object.EnumJobs( [ JobFilter ] ) as QueryResults

Part Description
object Expression that evaluates to an object in the Applies To list.
JobFilter Optional. A JobFilter object restricting result set membership.

Returns

A QueryResults object containing one result set defined by these columns.

Column Data type Description
job_id uniqueidentifier System-generated job identifier.
originating_server nvarchar(31) Network name of MSX server or the string (local).
name nvarchar(129) Job name.
enabled tinyint When 1, job is enabled.
description nvarchar(513) Descriptive text.
start_step_id integer User-defined job step identifier specified as first step executed.
category nvarchar(129) Job category name.
owner nvarchar(129) Microsoft® SQL Server™ database user identified as job owner.
notify_level_eventlog integer Execution outcome causing Microsoft Windows NT® application log entry. Interpret by using SQLDMO_COMPLETION_TYPE
notify_level_email integer Execution outcome causing operator notification by e-mail. Interpret by using SQLDMO_COMPLETION_
TYPE.
notify_level_netsend integer Execution outcome causing operator notification by network popup message. Interpret by using SQLDMO_COMPLETION_TYPE.
notify_level_page integer Execution outcome causing operator notification by page. Interpret by using SQLDMO_COMPLETION_
TYPE.
notify_email_operator nvarchar(129) Name of operator notified by e-mail.
notify_netsend_
operator
nvarchar(129) Name of operator notified by network popup message.
notify_page_operator nvarchar(129) Name of operator notified by page.
delete_level integer Execution outcome causing automated delete of job. Interpret by using SQLDMO_COMPLETION_
TYPE.
date_created smalldatetime Date and time at which job was created.
date_modified smalldatetime Date and time of most recent modification to job, job steps, or schedules.
version_number integer System-generated version number.
last_run_date integer Most recent date on which execution occurred formatted as described in Remarks.
last_run_time integer Time at which most recent execution occurred formatted as described in Remarks.
last_run_outcome integer Execution outcome of most recent execution attempt interpreted by using SQLDMO_JOBOUTCOME_
TYPE.
next_run_date integer When applicable, next scheduled execution date formatted as described in Remarks.
next_run_time integer When applicable, next scheduled execution time formatted as described in Remarks.
next_run_schedule_id integer Identifier of schedule generating next execution date and time.
current_execution_
status
integer Execution state interpreted by using SQLDMO_JOBEXECUTION_
STATUS.
current_execution_step nvarchar(129) When applicable, the currently executing step. A string formatted as the job step identifier, a space character, and the name of the step.
current_retry_attempt integer When applicable, the retry attempt for the job step.
has_step integer When 1, the job has at least one step defined.
has_schedule integer When 1, the job has at least one schedule enabled.
has_target integer When 1, the job has at least one execution target specified.
type integer Indicator of execution target interpreted by using SQLDMO_JOB_TYPE.

Remarks

The result set columns last_run_date and next_run_date represent execution dates as scaled long integers. The integers are 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 columns last_run_time and next_run_time represent execution times as scaled long integers. The integers are 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 JobFilter object. For more information, see JobFilter Object.

Prototype (C/C++)

HRESULT EnumJobs(
LPSQLDMOQUERYRESULTS* ppResults,
LPSQLDMOJOBFILTER pJobFilter = NULL);

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.