次の方法で共有


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'
    ディストリビューション サーバー名です。distributorsysname であり、既定値はありません。このパラメータは、リモート ディストリビュータを設定する場合にのみ使用します。このパラメータは、msdb..MSdistributor テーブルにディストリビュータ プロパティのエントリを追加します。

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

  • [ @password=] 'password']
    distributor_admin ログインのパスワードです。passwordsysname であり、既定値は 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'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 

権限

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