다음을 통해 공유


JobSchedules Collection

Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 않도록 하고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.

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

현재 개체를 보여 주는 SQL-DMO 개체 모델

Properties

주의

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 that references 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:

  • Define an execution schedule for a SQL Server Agent job.

  • Stop automated execution of a SQL Server Agent job by removing an execution schedule.

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

To stop automated execution of a SQL Server Agent job

  • Use the Remove method of the JobSchedules collection, as in:

    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)

[!참고]

Scheduling automated execution of SQL Server Agent jobs 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.