sp_dropdistributor (Transact-SQL)

適用対象: SQL ServerAzure SQL Managed Instance

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

Transact-SQL 構文表記規則

構文

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

引数

[ @no_checks = ] no_チェック

ディストリビューターを削除する前に、依存オブジェクトをチェックするかどうかを示します。 @no_チェックはビットで、既定値は 0.

  • の場合0チェック sp_dropdistributor 、ディストリビューターに加えて、すべてのパブリッシュ オブジェクトとディストリビューション オブジェクトが削除されたことを確認します。

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

[ @ignore_distributor = ] ignore_distributor

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

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

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

リターン コードの値

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

解説

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

他のパブリッシャー オブジェクトまたはディストリビューション オブジェクトがサーバー上に存在する場合、 sp_dropdistributor@no_チェックが .1

このストアド プロシージャは、ディストリビューション データベースを削除した後に実行する 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'AdventureWorks2022';

-- Disable the publication database.
USE [AdventureWorks2022]
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

アクセス許可

sysadmin 固定サーバー ロールのメンバーのみが実行sp_dropdistributorできます。