Udostępnij za pośrednictwem


sp_add_jobschedule (Transact-SQL)

Tworzy harmonogram dla zadanie.

Topic link iconKonwencje składni języka Transact-SQL

sp_add_jobschedule [ @job_id = ] job_id, | [ @job_name = ] 'job_name', [ @name = ] 'name'
     [ , [ @enabled = ] enabled_flag ]
     [ , [ @freq_type = ] frequency_type ]
     [ , [ @freq_interval = ] frequency_interval ]
     [ , [ @freq_subday_type = ] frequency_subday_type ]
     [ , [ @freq_subday_interval = ] frequency_subday_interval ]
     [ , [ @freq_relative_interval = ] frequency_relative_interval ]
     [ , [ @freq_recurrence_factor = ] frequency_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 ]
     [ , [ @schedule_id = ] schedule_id OUTPUT ]

Argumenty

  • [ @job_id= ] job_id
    Job identification number of the job to which the schedule is added.job_id is uniqueidentifier, with no default.

  • [ @job_name= ] 'job_name'
    Name of the job to which the schedule is added.job_name is nvarchar(128), with no default.

    Uwaga

    Albo job_id lub job_name musi być określona, ale nie może być jednocześnie określone.

  • [ @name= ] 'name'
    Name of the schedule.name is nvarchar(128), with no default.

  • [ @enabled= ] enabled_flag
    Indicates the current status of the schedule.enabled_flag is tinyint, with a default of 1 (enabled).Jeśli 0, harmonogram nie jest włączona.Po wyłączeniu harmonogramu zadanie nie uruchomi się.

  • [ @freq_type= ] frequency_type
    Value that indicates when the job is to be executed.frequency_type is int, with a default of 0, and can be one of the following values:

    Wartość

    Description

    1

    Tylko raz

    4

    Dzienne

    8

    Co tydzień

    16

    Miesięczne

    32

    Zmiana usługa dla trasa frequency_interval.

    64

    Podczas uruchamiania SQL Server Uruchamia usługa agenta.

    128

    Uruchomić, gdy komputer jest bezczynny.

  • [ @freq_interval= ] frequency_interval
    Day that the job is executed.frequency_interval is int, with a default of 0, and depends on the value of frequency_type as indicated in the following table:

    Wartość

    Efekt

    1 (tylko raz.)

    frequency_interval jest nieużywany.

    4 (codziennie)

    Co frequency_interval dni.

    8 (tydzień)

    frequency_interval jest co najmniej jedną z następujących czynności (w połączeniu z operator logicznego OR):

    1 = Niedziela

    2 = Poniedziałek

    4 = Wtorek

    8 = Środa

    16 = Czwartek

    32 = Piątek

    64 = Sobota

    16 (co miesiąc)

    Na frequency_interval dzień miesiąca.

    32 (miesięcznie względnie)

    frequency_interval jest jednym z następujących czynności:

    1 = Niedziela

    2 = Poniedziałek

    3 = Wtorek

    4 = Środa

    5 = Czwartek

    6 = Piątek

    7 = Sobota

    8 = Dzień

    9 = Dzień tygodnia

    10 = Dzień weekendu

    64 (Jeśli SQL Server Uruchamia usługa Agent)

    frequency_interval jest nieużywany.

    128

    frequency_interval jest nieużywany.

  • [ @freq_subday_type= ] frequency_subday_type
    Specifies the units for frequency_subday_interval.frequency_subday_type is int, with no default, and can be one of the following values:

    Wartość

    Opis (jednostki)

    0x1

    W określonym czas

    0x4

    Minutes

    0x8

    Hours

  • [ @freq_subday_interval= ] frequency_subday_interval
    Number of frequency_subday_type periods to occur between each execution of the job.frequency_subday_interval is int, with a default of 0.

  • [ @freq_relative_interval= ] frequency_relative_interval
    Dodatkowo definiuje frequency_interval Kiedy frequency_type jest ustawiona na 32 (względne co miesiąc).

    frequency_relative_interval jest int, z Brak domyślnej i może mieć jedną z następujących wartości:

    Wartość

    Opis (jednostki)

    1

    First

    2

    Sekundy

    4

    Trzecia

    8

    Czwarty

    16

    Last

    frequency_relative_interval Wskazuje wystąpienie danego okresu.Na przykład jeśli frequency_relative_interval jest zestaw do 2, frequency_type jest zestaw do 32, and frequency_interval jest zestaw do 3, zaplanowane zadanie zostanie wykonana w drugi wtorek każdego miesiąca.

  • [ @freq_recurrence_factor= ] frequency_recurrence_factor
    Number of weeks or months between the scheduled execution of the job.frequency_recurrence_factor is used only if frequency_type is set to 8, 16, or 32.frequency_recurrence_factor is int, with a default of 0.

  • [ @active_start_date= ] active_start_date
    Date on which job execution can begin.active_start_date is int, with no default.Data jest w formacie RRRRMMDD.Jeśli active_start_date jest ustawiony, data musi być większa lub równa 19900101.

    Jedna instrukcja SELECT może zainicjować wielu zmiennych lokalnych.Aby uzyskać więcej informacji zobacz sekcję "Planowanie data rozpoczęcia" w Creating and Attaching Schedules to Jobs.

  • [ @active_end_date= ] active_end_date
    Date on which job execution can stop.active_end_date is int, with no default.Data jest w formacie RRRRMMDD.

  • [ @active_start_time= ] active_start_time
    Time on any day between active_start_date and active_end_date to begin job execution.active_start_time is int, with no default.Czas jest w formacie HHMMSS na zegarze 24-godzinnym.

  • [ **@active_end_time=**active_end_time
    Time on any day between active_start_date and active_end_date to end job execution.active_end_time is int, with no default.Czas jest w formacie HHMMSS na zegarze 24-godzinnym.

  • [ @schedule_id=schedule_idOUTPUT
    Schedule identification number assigned to the schedule if it is created successfully.schedule_id is an output variable of type int, with no default.

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

Wartości kodów powrotnych

0 (sukces) lub 1 (brak)

Zestawy wyników

None

Remarks

Harmonogramy zadań można teraz zarządzać niezależnie od zadanie.Aby dodać harmonogram zadanie, należy użyć sp_add_schedule , aby utworzyć harmonogram i sp_attach_schedule dołączanie harmonogramu do zadanie.

Uprawnienia

Domyślnie członkowie sysadmin stała rola serwera możliwość wykonać tej procedura przechowywana.Inni użytkownicy klastrowa musi mieć jedną z następujących czynności SQL Server Agent stałe role bazy danych w msdb bazy danych:

  • SQLAgentUserRole

  • SQLAgentReaderRole

  • SQLAgentOperatorRole

Aby uzyskać szczegółowe informacje o uprawnieniach z tych ról zobacz SQL Server Agent Fixed Database Roles.

Historia zmian

Microsoft Learning

W poniższej tabela zestawiono formaty wprowadzania wyrażenie, które nie są prawidłowe i że powrócić, 0 lub błąd.