sp_attach_schedule (Transact-SQL)
Bir iş için zamanlama ayarlar.
sp_attach_schedule
{ [ @job_id = ] job_id | [ @job_name = ] 'job_name' } ,
{ [ @schedule_id = ] schedule_id
| [ @schedule_name = ] 'schedule_name' }
Bağımsız değişkenler
[ @job_id= ] job_id
The job identification number of the job to which the schedule is added.job_idis uniqueidentifier, with a default of NULL.[ @job_name = ] 'job_name'
The name of the job to which the schedule is added.job_nameis sysname, with a default of NULL.Not
Her iki job_id veya job_name belirtilmiş olması gerekir, ancak her ikisi de belirtilemiyor.
[ @schedule_id = ] schedule_id
The schedule identification number of the schedule to set for the job.schedule_idis int, with a default of NULL.[ @schedule_name = ] 'schedule_name'
The name of the schedule to set for the job.schedule_nameis sysname, with a default of NULL.Not
Her iki schedule_id veya schedule_name belirtilmiş olması gerekir, ancak her ikisi de belirtilemiyor.
Remarks
Zamanlamayı ve iş aynı sahip olması gerekir.
Zamanlama olabilir küme birden fazla iş.Bir iş, birden fazla zamanlamaya göre çalıştırabilirsiniz.
Bu saklı yordam, gelen çalıştırılmalıdır msdb veritabanıdır.
İzinler
Varsayılan olarak, üye sysadmin sunucu rolünü can sabit yürütmek Bu saklı yordamını.Aşağıdakilerden birini diğer kullanıcılara verilmelidir SQL Server Veritabanı rollerini sabit Aracısı msdb veritabanı:
SQLAgentUserRole
SQLAgentReaderRole
SQLAgentOperatorRole
Bu roller, izinler hakkında daha fazla bilgi için bkz: SQL Server Agent Database Roles sabit.
SQL Server Kullanıcı hem iş hem de zamanlamayı sahibi denetler.
Örnekler
Aşağıdaki örnek, adlı bir zamanlama oluşturur. NightlyJobs. Bu zamanlamayı kullan işleri her gün, saat sunucusundaki olduğunda yürütmek 01:00. Örnek işi zamanlamayı iliştirir. BackupDatabase ve iş RunReports.
Not
Bu örnek, varsayar iş BackupDatabase ve iş RunReports zaten mevcut.
USE msdb ;
GO
EXEC sp_add_schedule
@schedule_name = N'NightlyJobs' ,
@freq_type = 4,
@freq_interval = 1,
@active_start_time = 010000 ;
GO
EXEC sp_attach_schedule
@job_name = N'BackupDatabase',
@schedule_name = N'NightlyJobs' ;
GO
EXEC sp_attach_schedule
@job_name = N'RunReports',
@schedule_name = N'NightlyJobs' ;
GO