sp_adddistributor (języka Transact-SQL)

Tworzy wpis w sys.sysservers tabela (Jeśli nie ma jeden) oznacza wpisu serwera jako dystrybutorzy i przechowuje właściwość informacji.Ta procedura składowana jest wykonywany dystrybutor na baza danych master do rejestrowania i oznaczyć serwera jako dystrybutorzy.W odniesieniu do zdalnego dystrybutor, również jest ono wykonane na Wydawca z wzorca bazy danych do rejestrowania zdalnego dystrybutor.

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

Składnia

sp_adddistributor [ @distributor= ] 'distributor' 
    [ , [ @heartbeat_interval= ] heartbeat_interval ] 
    [ , [ @password= ] 'password' ] 
    [ , [ @from_scripting= ] from_scripting ]

Argumenty

  • [ @ dystrybutor = 'dystrybutor"
    Is the distribution server name.distributor is sysname, with no default.Ten parametr jest używany wyłącznie konfigurowania dystrybutor zdalny.Dodaje wpisy dla właściwości dystrybutora w msdb.MSdistributor tabela.

  • [ @ heartbeat_interval = heartbeat_interval
    Is the maximum number of minutes that an agent can go without logging a progress message.heartbeat_interval is int, with a default of 10 minutes.A SQL Server jest uruchamiana na ten interwał, aby sprawdzić stan agenci replikacja uruchomionych utworzone zadanie agenta.

  • [ @ hasło = 'hasło'
    Is the password of the distributor_admin login.password is sysname, with a default of NULL.Jeśli ZEROWY lub pusty ciąg hasła jest ustawiany na wartość losowe.The password must be configured when the first remote distributor is added.distributor_admin login and password are stored for linked server entry used for a distributor RPC connection, including local connections.Jeśli dystrybutor lokalnego, hasło distributor_admin jest zestaw nową wartość.For Publishers with a remote Distributor, the same value for password must be specified when executing sp_adddistributor at both the Publisher and Distributor.sp_changedistributor_password can be used to change the Distributor password.

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

    Jeśli to możliwe, monitują użytkowników o wprowadzenie poświadczenia zabezpieczeń w czasie wykonywania.Jeśli poświadczenia muszą być przechowywane w pliku skryptu, należy zabezpieczyć plik, aby uniemożliwić nieautoryzowany dostęp.

  • [ @ from_scripting = from_scripting
    Określone tylko w celach informacyjnych. Nieobsługiwane. Przyszła zgodność nie jest gwarantowana.

Wartości kodów powrotnych

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

Uwagi

sp_adddistributor w replikacja migawka, replikacja transakcyjna i scalania replikacji.

Przykład

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). 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".

-- Install the Distributor and the distribution database.
DECLARE @distributor AS sysname;
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @directory AS nvarchar(500);
DECLARE @publicationDB AS sysname;
-- Specify the Distributor name.
SET @distributor = $(DistPubServer);
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);
-- Specify the replication working directory.
SET @directory = N'\\' + $(DistPubServer) + '\repldata';
-- Specify the publication database.
SET @publicationDB = N'AdventureWorks2008R2'; 

-- Install the server MYDISTPUB as a Distributor using the defaults,
-- including autogenerating the distributor password.
USE master
EXEC sp_adddistributor @distributor = @distributor;

-- Create a new distribution database using the defaults, including
-- using Windows Authentication.
USE master
EXEC sp_adddistributiondb @database = @distributionDB, 
    @security_mode = 1;
GO

-- Create a Publisher and enable AdventureWorks2008R2 for replication.
-- Add MYDISTPUB as a publisher with MYDISTPUB as a local distributor
-- and use Windows Authentication.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);

USE [distribution]
EXEC sp_adddistpublisher @publisher=@publisher, 
    @distribution_db=@distributionDB, 
    @security_mode = 1;
GO 

Uprawnienia

Tylko członkowie sysadmin stała rola serwera można wykonać sp_adddistributor.