JobSchedules Collection (SQL-DMO)

The JobSchedules collection contains JobSchedule objects, each referencing one execution schedule for a SQL Server Agent job.

Remarks

A SQL Server Agent job defines an administrative task. A job may or may not be scheduled. When scheduled, SQL Server Agent evaluates the schedule or schedules associated with the job and attempts automated execution of the job at the time(s) defined by the schedule(s). When not scheduled, a job may be executed on-demand by a properly authorized user.

When a SQL Server Agent job is scheduled, the JobSchedules collection of the Job object referencing the job contains one or more JobSchedule objects. Use the Count property to determine the number of schedules established for the job. When the Count property of a JobSchedules collection returns 0, the job has no automated execution schedule. Use the Start method of the Job object to execute the referenced job.

With the JobSchedules collection, you can:

For more information about scheduling job execution by adding a JobSchedule to the JobSchedules collection, see JobSchedule Object.

To stop automated execution of a SQL Server Agent job

    oJob.JobSchedules.Remove("Northwind_Hourly_Log_Backup")

  

When using the Item or Remove method, the JobSchedules collection supports member identification using either name or ordinal reference syntax. For example:

Set oJobSchedule = oJob.JobSchedules("Northwind_Backup_DB")

  

Or:

Set oJobSchedule = oJob.JobSchedules(1)

  


Note Scheduling automated execution of SQL Server Agent jobs by using the JobSchedules collection requires appropriate privilege. The Microsoft® SQL Server™ login used for SQLServer object connection must be a member of the fixed role public in the system database msdb. With public membership, the connection may schedule jobs belonging to the connected login. Members of the db_owner role in msdb, or members of a role with greater privilege, can schedule any SQL Server Agent job.


Methods
Add Method Refresh Method
Item Method Remove Method (Collections)
ItemByID Method  

Properties

Count Property

  


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