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.
Properties
説明
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
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 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.
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.