sp_addpublication_snapshot (języka Transact-SQL)

Tworzy Agent migawki dla określonej publikacja.Ta procedura składowana jest wykonywany na Wydawca na bazie publikacja.

Uwaga dotycząca zabezpieczeńUwaga dotycząca zabezpieczeń

Podczas konfigurowania Publisher z dystrybutor zdalny, wartości dostarczone dla wszystkich parametrów, łącznie z job_login i job_password, są wysyłane do dystrybutora jako zwykły tekst.Należy zaszyfrować połączenie między wydawcy i jego dystrybutor zdalny przed wykonywania tej procedura składowana.Aby uzyskać więcej informacji, zobacz Szyfrowania połączeńSQL Server.

Ikona łącza do tematuKonwencje składni Transact-SQL

Składnia

sp_addpublication_snapshot [ @publication= ] 'publication'
    [ , [ @frequency_type= ] frequency_type ]
    [ , [ @frequency_interval= ] frequency_interval ]
    [ , [ @frequency_subday= ] frequency_subday ]
    [ , [ @frequency_subday_interval= ] frequency_subday_interval ]
    [ , [ @frequency_relative_interval= ] frequency_relative_interval ]
    [ , [ @frequency_recurrence_factor= ] frequency_recurrence_factor ]
    [ , [ @active_start_date= ] active_start_date ]
    [ , [ @active_end_date= ] active_end_date ]
    [ , [ @active_start_time_of_day= ] active_start_time_of_day ]
    [ , [ @active_end_time_of_day= ] active_end_time_of_day ]
    [ , [ @snapshot_job_name = ] 'snapshot_agent_name' ]
    [ , [ @publisher_security_mode = ] publisher_security_mode ]
    [ , [ @publisher_login = ] 'publisher_login' ]
    [ , [ @publisher_password = ] 'publisher_password' ] 
    [ , [ @job_login = ] 'job_login' ]
    [ , [ @job_password = ] 'job_password' ]
    [ , [ @publisher = ] 'publisher' ]

Argumenty

  • [ @ publikacja = 'publication"
    Is the name of the publication.publication is sysname, with no default.

  • [ @ frequency_type = frequency_type
    Is the frequency with which the Snapshot Agent is executed.frequency_type is int, and can be one of the following values.

    Wartość

    Opis

    1

    Tylko raz.

    4 (domyślnie)

    Dzienny.

    8

    Co tydzień.

    16

    Miesięczne.

    32

    Miesięczne względem interwał częstotliwości.

    64

    Gdy SQL Server uruchomieniu agenta.

    128

    Uruchom, kiedy komputer jest bezczynny

  • [ @ frequency_interval = frequency_interval
    Is the value to apply to the frequency set by frequency_type.frequency_interval is int, and can be one of the following values.

    Wartość frequency_type

    Wpływ na frequency_interval

    1

    frequency_interval jest nieużywany.

    4 (domyślnie)

    Każdy frequency_interval dni domyślnie codziennie.

    8

    frequency_intervalma jedną lub więcej z następujących czynności (w połączeniu z | (Wartość logiczną lub) operator logicznego):

    1 = Niedziela |

    2 = Poniedziałek |

    4 = Wtorek |

    8 = Środa |

    16 = Czwartek |

    32 = Piątek |

    64 = Sobota

    16

    Na frequency_interval dzień miesiąca.

    32

    frequency_intervaljest jedną z następujących czynności:

    1 = Niedziela |

    2 = Poniedziałek |

    3 = Wtorek |

    4 = Środa |

    5 = Czwartek |

    6 = Piątek |

    7 = Sobota |

    8 = Day |

    9 =Dzień.TYG("05-12-99"=1) |

    10 = Dzień wolny

    64

    frequency_interval jest nieużywany.

    128

    frequency_interval jest nieużywany.

  • [ @ frequency_subday = frequency_subday
    Is the unit for freq_subday_interval.frequency_subday is int, and can be one of these values.

    Wartość

    Opis

    1

    Raz

    2

    Drugie

    4 (domyślnie)

    Minuta

    8

    Godziny

  • [ @ frequency_subday_interval = frequency_subday_interval
    Is the interval for frequency_subday.frequency_subday_interval is int, with a default of 5, which means every 5 minutes.

  • [ @ frequency_relative_interval = frequency_relative_interval
    Is the date the Snapshot Agent runs.frequency_relative_interval is int, with a default of 1.

  • [ @ frequency_recurrence_factor = frequency_recurrence_factor
    Is the recurrence factor used by frequency_type.frequency_recurrence_factor is int, with a default of 0.

  • [ @ active_start_date = active_start_date
    Is the date when the Snapshot Agent is first scheduled, formatted as YYYYMMDD.active_start_date is int, with a default of 0.

  • [ @ active_end_date = active_end_date
    Is the date when the Snapshot Agent stops being scheduled, formatted as YYYYMMDD.active_end_date is int, with a default of 99991231, which means December 31, 9999.

  • [ @ active_start_time_of_day = active_start_time_of_day
    Is the time of day when the Snapshot Agent is first scheduled, formatted as HHMMSS.active_start_time_of_day is int, with a default of 0.

  • [ @ active_end_time_of_day = active_end_time_of_day
    Is the time of day when the Snapshot Agent stops being scheduled, formatted as HHMMSS.active_end_time_of_day is int, with a default of 235959, which means 11:59:59 P.M.as measured on a 24-hour clock.

  • [ @ snapshot_job_name = 'snapshot_agent_name"
    Is the name of an existing Snapshot Agent job name if an existing job is being used.snapshot_agent_name is nvarchar(100) with a default value of NULL.Ten parametr jest do użytku wewnętrznego i nie powinien być określony podczas tworzenia nowej publikacja.Jeśli snapshot_agent_name jest określony, następnie job_login i job_password musi być NULL.

  • [ @ publisher_security_mode=] publisher_security_mode
    Is the security mode used by the agent when connecting to the Publisher.publisher_security_mode is smallint, with a default of 1.0 Określa SQL Server uwierzytelniania, i 1 Określa uwierzytelnianie systemu Windows.Wartość 0 musi być określona dla nie-SQL Server wydawcy. Gdy jest to możliwe, należy używać uwierzytelniania systemu Windows.

  • [ @ publisher_login=] 'publisher_login"
    Is the login used when connecting to the Publisher.publisher_login is sysname, with a default of NULL.publisher_login must be specified when publisher_security_mode is 0.Jeśli publisher_login ma wartość NULL i publisher_security_mode jest 1, a następnie konto systemu Windows, określone w job_login będą używane podczas łączenia się z Wydawca.

  • [ @ publisher_password=] 'publisher_password"
    Is the password used when connecting to the Publisher.publisher_password is sysname, with a default of NULL.

    Uwaga dotycząca zabezpieczeńUwaga dotycząca zabezpieczeń

    Nie przechowuj uwierzytelnianie informacji w plikach skryptów.Aby poprawić zabezpieczenia zaleca się dostarczyć nazwy logowania i hasła przy uruchomieniu czas.

  • [ @ job_login=] 'job_login"
    Is the login for the Windows account under which the agent runs.job_login is nvarchar(257), with a default of NULL.To konto systemu Windows jest zawsze używana dla połączeń agenta do dystrybutora.Ten parametr należy podać podczas tworzenia nowego zadanie agenta migawki.

    Ostrzeżenie

    Dla nie-SQL Server wydawcy, musi to być tym samym logowania określony w sp_adddistpublisher (języka Transact-SQL).

  • [ @ job_password=] 'job_password"
    Is the password for the Windows account under which the agent runs.job_password is sysname, with no default.Ten parametr należy podać podczas tworzenia nowego zadanie agenta migawki.

    Uwaga dotycząca zabezpieczeńUwaga dotycząca zabezpieczeń

    Nie przechowuj uwierzytelnianie informacji w plikach skryptów.Aby poprawić zabezpieczenia zaleca się dostarczyć nazwy logowania i hasła przy uruchomieniu czas.

  • [ program publisher @ =] 'publisher"
    Specifies a non-SQL Server Publisher.publisher is sysname, with a default of NULL.

    Ostrzeżenie

    publishernie należy używać podczas tworzenia agenta migawki na SQL Server Wydawca.

Wartości kodów powrotnych

0 (sukces) lub 1 (błąd)

Uwagi

sp_addpublication_snapshot w replikacja migawka, replikacja transakcyjna i scalania replikacji.

Przykład

-- To avoid storing the login and password in the script file, the values 
-- are passed into SQLCMD as scripting variables. For information about 
-- how to use scripting variables on the command line and in SQL Server
-- Management Studio, see the "Executing Replication Scripts" section in
-- the topic "Programming Replication Using System Stored Procedures".

DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
DECLARE @login AS sysname;
DECLARE @password AS sysname;
SET @publicationDB = N'AdventureWorks2008R2'; 
SET @publication = N'AdvWorksProductTran'; 
-- Windows account used to run the Log Reader and Snapshot Agents.
SET @login = $(Login); 
-- This should be passed at runtime.
SET @password = $(Password); 

-- Enable transactional or snapshot replication on the publication database.
EXEC sp_replicationdboption 
    @dbname=@publicationDB, 
    @optname=N'publish',
    @value = N'true';

-- Execute sp_addlogreader_agent to create the agent job. 
EXEC sp_addlogreader_agent 
    @job_login = @login, 
    @job_password = @password,
    -- Explicitly specify the use of Windows Integrated Authentication (default) 
    -- when connecting to the Publisher.
    @publisher_security_mode = 1;

-- Create a new transactional publication with the required properties. 
EXEC sp_addpublication 
    @publication = @publication, 
    @status = N'active',
    @allow_push = N'true',
    @allow_pull = N'true',
    @independent_agent = N'true';

-- Create a new snapshot job for the publication, using a default schedule.
EXEC sp_addpublication_snapshot 
    @publication = @publication, 
    @job_login = @login, 
    @job_password = @password,
    -- Explicitly specify the use of Windows Integrated Authentication (default) 
    -- when connecting to the Publisher.
    @publisher_security_mode = 1;
GO

Uprawnienia

Tylko członkowie sysadmin stała rola serwera lub db_owner ustaloną rola bazy danych można wykonać sp_addpublication_snapshot.