Schedule Object (SQL-DMO)
The Schedule object exposes the attributes of a timetable for automated Microsoft® SQL Server™ tasks, such as jobs and replication publication.
Remarks
SQL Server Agent automates administration and replication tasks. Any task automated by SQL Server Agent can be scheduled for one-time or repeated execution. 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 even 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
- 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.
- Use the BeginAlter method of the Schedule object to mark the start of changes to the timetable.
- Set the ActiveStartDate property to the date you want the task to execute. The date properties of a Schedule object pack a date string into a long integer value as the year, scaled by 10,000, plus the month, scaled by 100, plus the day. For example, December 1, 1997 is represented by the integer 19971201.
- Set the ActiveStartTimeOfDay property to the time you want the task to execute.
- Set the ActiveEndDate and ActiveEndTimeOfDay properties to a day and time later than the day and time you want the task to execute.
- Set the FrequencyType property to SQLDMOFreq_OneTime.
- 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
- Get the Schedule object required from the appropriate object referencing the task.
- Use the BeginAlter method of the Schedule object to mark the start of changes to the timetable.
- Set the ActiveStartDate and ActiveEndDate properties to the dates you want the timetable to become effective and no longer effective.
- Set the ActiveStartTimeOfDay property to the time you want SQL Server Agent to execute the task.
- Set the ActiveEndTimeOfDay property to a time greater than the start time for the task.
- Set the FrequencyType property to SQLDMOFreq_Weekly.
- 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.
- Use the DoAlter method to mark the end of changes to the Schedule object and submit the changes to SQL Server.
Methods
Properties
(c) 1988-98 Microsoft Corporation. All Rights Reserved.