Aracılığıyla paylaş


sp_add_schedule (Transact-SQL)

Herhangi bir sayıda işleri kullanılabilecek bir zamanlama planı oluşturur.

Topic link iconTransact-SQL sözdizimi kuralları

sp_add_schedule [ @schedule_name = ] 'schedule_name' 
    [ , [ @enabled = ] enabled ]
    [ , [ @freq_type = ] freq_type ]
    [ , [ @freq_interval = ] freq_interval ] 
    [ , [ @freq_subday_type = ] freq_subday_type ] 
    [ , [ @freq_subday_interval = ] freq_subday_interval ] 
    [ , [ @freq_relative_interval = ] freq_relative_interval ] 
    [ , [ @freq_recurrence_factor = ] freq_recurrence_factor ] 
    [ , [ @active_start_date = ] active_start_date ] 
    [ , [ @active_end_date = ] active_end_date ] 
    [ , [ @active_start_time = ] active_start_time ] 
    [ , [ @active_end_time = ] active_end_time ] 
    [ , [ @owner_login_name = ] 'owner_login_name' ]
    [ , [ @schedule_uid = ] schedule_uid OUTPUT ]
    [ , [ @schedule_id = ] schedule_id OUTPUT ]
    [ , [ @originating_server = ] server_name ] /* internal */

Bağımsız değişkenler

  • [ @schedule_name = ] 'schedule_name'
    The name of the schedule.schedule_nameis sysname, with no default.

  • [ @enabled = ] enabled
    Indicates the current status of the schedule.enabledis tinyint, with a default of 1 (enabled).If0, zamanlamayı etkinleştirilmez.Zamanlamayı etkin olduğunda, işi yok bu zamanlamaya göre çalışır.

  • [ @freq_type = ] freq_type
    A value indicating when a job is to be executed.freq_typeis int, with a default of 0, and can be one of these values.

    Değer

    Açıklama

    1

    Bir kez

    4

    Günlük

    8

    Haftalık

    16

    Aylık

    32

    Aylık göre freq_interval

    64

    SQLServerAgent hizmet başladığında başlatma

    128

    Bilgisayar boştayken çalıştırma

  • [ @freq_interval = ] freq_interval
    The days that a job is executed.freq_interval is int, with a default of 1, and depends on the value of freq_type.

    Değeri freq_type

    Etkisi freq_interval

    1 (bir kez)

    freq_interval kullanılmaz.

    4 (günlük)

    Herfreq_intervalgün.

    8 (Haftalık)

    freq_intervalbiri veya daha fazlasını (veya mantıksal işleç ile birlikte):

    1 = Sunday

    2 = Monday

    4 = Tuesday

    8 Çarşamba =

    16 Perşembe =

    32 = Friday

    64 Cumartesi =

    16 (aylık)

    ,freq_intervalgün, ay.

    32 (aylık göreli)

    freq_intervalaşağıdakilerden biridir:

    1 = Sunday

    2 = Monday

    3 = Tuesday

    4 Çarşamba =

    5 Perşembe =

    6 = Friday

    7 Cumartesi =

    8 = Day

    9 = Weekday

    10 = $ Hafta günü

    64 (SQLServerAgent hizmet başlatıldığında)

    freq_interval kullanılmaz.

    128

    freq_interval kullanılmaz.

  • [ @freq_subday_type = ] freq_subday_type
    Specifies the units for freq_subday_interval.freq_subday_typeis int, with a default of 0, and can be one of these values.

    Değer

    Açıklama (birim)

    0x1

    Belirli bir zamanda

    0x4

    Minutes

    0x8

    Hours

  • [ @freq_subday_interval = ] freq_subday_interval
    The number of freq_subday_type periods to occur between each execution of a job.freq_subday_intervalis int, with a default of 0.freq_subday_interval is ignored in those cases where freq_subday_type is equal to 1.

  • [ @freq_relative_interval = ] freq_relative_interval
    A job's occurrence of freq_interval in each month, if freq_interval is 32 (monthly relative).freq_relative_intervalis int, with a default of 0, and can be one of these values.freq_relative_interval is ignored in those cases where freq_type is not equal to 32.

    Değer

    Açıklama (birim)

    1

    First

    2

    İkinci

    4

    Üçüncü

    8

    Dördüncü

    16

    Last

  • [ @freq_recurrence_factor = ] freq_recurrence_factor
    The number of weeks or months between the scheduled execution of a job.freq_recurrence_factor is used only if freq_type is 8, 16, or 32.freq_recurrence_factoris int, with a default of 0.

  • [ @active_start_date = ] active_start_date
    The date on which execution of a job can begin.active_start_dateis int, with a default of NULL, which indicates today's date.Tarih, ALAN biçimlendirilir.Ifactive_start_dateNULL, değil tarih 19900101 ya da daha büyük olmalıdır.

    Zamanlamayı oluşturulduktan sonra başlangıç tarihini gözden geçirin ve doğru tarih olduğunu onaylayın.Daha fazla bilgi için bkz "başlangıç tarih planlama" bölümüOluşturma ve projeler için çizelgeler ekleme.

  • [ @active_end_date = ] active_end_date
    The date on which execution of a job can stop.active_end_dateis int, with a default of 99991231, which indicates December 31, 9999.YYYYAAGG biçimlendirilmiş.

  • [ @active_start_time = ] active_start_time
    The time on any day between active_start_date and active_end_date to begin execution of a job.active_start_timeis int, with a default of 000000, which indicates 12:00:00 A.M.on a 24-hour clock, and must be entered using the form HHMMSS.

  • [ @active_end_time = ] active_end_time
    The time on any day between active_start_date and active_end_date to end execution of a job.active_end_timeis int, with a default of 235959, which indicates 11:59:59 P.M.on a 24-hour clock, and must be entered using the form HHMMSS.

  • [ @ owner_login_name= ] 'owner_login_name'
    The name of the server principal that owns the schedule.owner_login_name is sysname, with a default of NULL, which indicates that the schedule is owned by the creator.

  • [ @schedule_uid= ] schedule_uidOUTPUT
    A unique identifier for the schedule.schedule_uid is a variable of type uniqueidentifier.

  • [ @schedule_id= ] schedule_idOUTPUT
    An identifier for the schedule.schedule_id is a variable of type int.

  • [ @ originating_server= ] server_name
    Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.

Dönüş Kodu Değerleri

0 (başarılı) veya 1 (hata)

Sonuç Kümeleri

None

Remarks

SQL Server Management Studio oluşturmak ve iş altyapısını yönetmek için önerilen yoldur ve işleri yönetmek için kolay ve grafiksel bir yöntem sağlar.

İzinler

Varsayılan olarak, üye sysadmin sabit sunucu rolü Bu saklı yordamı çalıştırabilirsiniz.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.

Örnekler

C.Zamanlama oluşturma

Aşağıdaki örnek, adlı bir zamanlama oluştururRunOnce.Zamanlama sırasında saat çalıştırır23:30zamanlamayı oluşturduğunuz gün.

USE msdb ;
GO

EXEC dbo.sp_add_schedule
    @schedule_name = N'RunOnce',
    @freq_type = 1,
    @active_start_time = 233000 ;

GO

b.Zamanlama için birden çok iş zamanlama ekleme, oluşturma

Aşağıdaki örnek, adlı bir zamanlama oluştururNightlyJobs.Bu zamanlamayı kullanan işleri yürütmek saat sunucu üzerinde olduğunda her gün01:00.Örnek proje zamanlamaya eklerBackupDatabaseve işRunReports.

Not

Bu örnek, varsayar işBackupDatabaseve işRunReportszaten.

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

Değişiklik Geçmişi

Güncelleştirilmiş içerik

Başlangıç tarih parametresi bir plan oluşturduktan sonra başlangıç tarihini onaylama hakkında bilgiler içerir.