다음을 통해 공유


Schedule Object

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

The Schedule object exposes the attributes of a timetable for automated Microsoft SQL Server tasks, such as jobs and replication publication.

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

Properties

ActiveEndDate Property

FrequencyRecurrenceFactor Property

ActiveEndTimeOfDay Property

FrequencyRelativeInterval Property

ActiveStartDate Property

FrequencySubDay Property

ActiveStartTimeOfDay Property

FrequencySubDayInterval Property

FrequencyInterval Property

FrequencyType Property

Methods

BeginAlter Method

DoAlter Method

CancelAlter Method

Refresh Method

주의

SQL Server Agent automates administration and replication tasks. Any task automated by the SQL Server Agent can be scheduled to run once only or repeatedly. The timetable for repeated execution can be elaborate, specifying that the task execute monthly on a given day of a given week, weekly on one or more days, or every minute of every day.

With the Schedule object, you can:

  • Set or adjust the execution timetable for a SQL Server Agent job schedule.
  • Set or adjust the execution timetable for SQL Server replication article publication and pull subscriptions.

To schedule one-time execution of a SQL Server executable task

  1. Get the Schedule object required from the appropriate object referencing the task. For example, to adjust a SQL Server Agent job schedule, get the Schedule object from the JobSchedule object that references the SQL Server Agent job schedule.

  2. Use the BeginAlter method of the Schedule object to mark the start of changes to the timetable.

  3. Set the ActiveStartDate property to the date you want the task to execute. The date properties of a Schedule object require a long integer value that represents the date by taking the year, scaled by 10,000, then adding the month, scaled by 100, then adding the day. For example, December 1, 1997 is represented by the integer 19971201.

  4. Set the ActiveStartTimeOfDay property to the time you want the task to execute.

  5. Set the ActiveEndDate and ActiveEndTimeOfDay properties to a day and time later than the day and time you want the task to execute.

  6. Set the FrequencyType property to SQLDMOFreq_OneTime.

  7. Use the DoAlter method to mark the end of changes to the Schedule object and submit those changes to SQL Server.

To schedule a SQL Server executable task for weekly execution on specified days

  1. Get the Schedule object required from the appropriate object referencing the task.

  2. Use the BeginAlter method of the Schedule object to mark the start of changes to the timetable.

  3. Set the ActiveStartDate and ActiveEndDate properties to the dates you want the timetable to become effective and no longer effective.

  4. Set the ActiveStartTimeOfDay property to the time you want SQL Server Agent to execute the task.

  5. Set the ActiveEndTimeOfDay property to a time greater than the start time for the task.

  6. Set the FrequencyType property to SQLDMOFreq_Weekly.

  7. Set the FrequencyInterval property to the days the task should run. The value can be specified as a single-day constant or a binary OR of day constants. For example, to set the property for weekly execution of the task on Sunday, use the constant SQLDMOWeek_Sunday. To specify Monday, Wednesday, and Friday, use a binary OR of the constants SQLDMOWeek_Monday, SQLDMOWeek_Wednesday, and SQLDMOWeek_Friday.

  8. Use the DoAlter method to mark the end of changes to the Schedule object and submit the changes to SQL Server.