Share via


sp_dropdistributor (Transact-SQL)

ディストリビュータをアンインストールします。このストアド プロシージャは、ディストリビュータ側でディストリビューション データベースを除くすべてのデータベースについて実行されます。

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

構文

sp_dropdistributor [ [ @no_checks= ] no_checks ] 
    [ , [ @ignore_distributor= ] ignore_distributor ]

引数

  • [ @no_checks=] no_checks
    ディストリビュータを削除する前に、従属オブジェクトを確認するかどうかを指定します。no_checks のデータ型は bit で、既定値は 0 です。

    0 の場合、sp_dropdistributor は、ディストリビュータだけでなく、すべてのパブリッシュ オブジェクトおよびディストリビューション オブジェクトが削除されているかを確認します。

    1 の場合、sp_dropdistributor は、ディストリビュータをアンインストールする前にパブリッシング オブジェクトとディストリビューション オブジェクトを削除します。

  • [ @ignore_distributor=] ignore_distributor
    ディストリビュータに接続せずに、このストアド プロシージャを実行するかどうかを指定します。ignore_distributor のデータ型は bit で、既定値は 0 です。

    0 の場合、sp_dropdistributor はディストリビュータに接続し、すべてのレプリケーション オブジェクトを削除します。sp_dropdistributor がディストリビュータに接続できない場合、ストアド プロシージャは失敗します。

    1 の場合、ディストリビュータには接続せず、レプリケーション オブジェクトは削除されません。これが使用されるのは、ディストリビュータがアンインストールされているか、完全にオフラインになっている場合です。ディストリビュータでのパブリッシャに関連するオブジェクトは、後でディストリビュータが再インストールされるまで削除されません。

戻り値

0 (成功) または 1 (失敗)

説明

sp_dropdistributor は、すべての種類のレプリケーションで使用します。

他のパブリッシャ オブジェクトまたはディストリビューション オブジェクトがサーバーに存在する場合、@no_checks1 に設定されていない限り、sp_dropdistributor は失敗します。

sp_dropdistributiondb を実行してディストリビューション データベースを削除した後で、このストアド プロシージャを実行する必要があります。

使用例

-- 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".

-- Disable publishing and distribution.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB as sysname;
SET @distributionDB = N'distribution';
SET @publisher = $(DistPubServer);
SET @publicationDB = N'AdventureWorks2008R2';

-- Disable the publication database.
USE [AdventureWorks2008R2]
EXEC sp_removedbreplication @publicationDB;

-- Remove the registration of the local Publisher at the Distributor.
USE master
EXEC sp_dropdistpublisher @publisher;

-- Delete the distribution database.
EXEC sp_dropdistributiondb @distributionDB;

-- Remove the local server as a Distributor.
EXEC sp_dropdistributor;
GO

権限

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