Share via


sp_adddistributor (Transact-SQL)

sys.sysservers テーブル内にエントリがない場合、エントリを作成し、そのサーバー エントリにディストリビューターのマークを付けて、プロパティ情報を格納します。 このストアド プロシージャは、ディストリビューター側で master データベースについて実行され、サーバーをディストリビューターとして登録し、サーバーにディストリビューターのマークを付けます。 リモート ディストリビューターの場合、このストアド プロシージャは、master データベースからパブリッシャー側でも実行され、リモート ディストリビューターを登録します。

トピック リンク アイコン Transact-SQL 構文表記規則

構文

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

引数

  • [ @distributor=] 'distributor'
    ディストリビューション サーバー名です。 distributor のデータ型は sysname で、既定値はありません。 このパラメーターは、リモート ディストリビューターを設定する場合にのみ使用します。 このパラメーターは、msdb..MSdistributor テーブルにディストリビューター プロパティのエントリを追加します。

  • [ @heartbeat_interval=] heartbeat_interval
    エージェントが進捗状況を示すメッセージをログに記録しなくてもよい最大時間を分単位で示します。 heartbeat_interval のデータ型は int で、既定値は 10 分です。 この間隔で実行され、実行中のレプリケーション エージェントの状態を確認する SQL Server エージェント ジョブが作成されます。

  • [ @password=] 'password']
    distributor_admin ログインのパスワードです。 password のデータ型は sysname で、既定値は NULL です。 NULL または空の文字列である場合、パスワードはランダムな値に再設定されます。 パスワードは最初のリモート ディストリビューターを追加するときに構成する必要があります。 distributor_admin ログインと password は、ローカル接続を含む distributor の RPC 接続に使用されるリンク サーバー エントリ用に格納されます。 distributor がローカルの場合、distributor_admin のパスワードは新しい値に設定されます。 リモート ディストリビューターを持つパブリッシャーの場合、パブリッシャーとディストリビューターの両方で sp_adddistributor を実行するときに、password に同じ値を指定する必要があります。 sp_changedistributor_password を使用すると、ディストリビューターのパスワードを変更できます。

    セキュリティに関する注意セキュリティに関する注意

    可能であれば、実行時にセキュリティ資格情報の入力を求めるメッセージをユーザーに対して表示します。 スクリプト ファイルに資格情報を格納する場合は、不正アクセスを防ぐために、そのファイルをセキュリティで保護する必要があります。

  • [ @from_scripting= ] from_scripting
    単に情報を示すためだけに特定されます。サポートされていません。将来の互換性は保証されません。

戻り値

成功した場合は 0 を、失敗した場合は 1 をそれぞれ返します。

説明

sp_adddistributor は、スナップショット レプリケーション、トランザクション レプリケーション、およびマージ レプリケーションで使用します。

使用例

-- 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'AdventureWorks2012'; 

-- 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 AdventureWorks2012 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 

権限

sp_adddistributor を実行できるのは、固定サーバー ロール sysadmin のメンバーだけです。

関連項目

参照

sp_changedistributor_property (Transact-SQL)

sp_dropdistributor (Transact-SQL)

sp_helpdistributor (Transact-SQL)

システム ストアド プロシージャ (Transact-SQL)

概念

パブリッシングおよびディストリビューションの構成

ディストリビューションの構成