Compartir a través de


Schedule Object

Esta característica se quitará en una versión futura de Microsoft SQL Server. Evite utilizar esta característica en nuevos trabajos de desarrollo y tenga previsto modificar las aplicaciones que actualmente la utilizan.

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

Modelo de objeto SQL-DMO con el objeto actual

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

Notas

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.