sp_dropdistributor (Transact-SQL)

解除安裝散發者。這個預存程序執行於散發資料庫以外任何資料庫的散發者端。

主題連結圖示Transact-SQL 語法慣例

語法

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

引數

  • [@no_checks=] no_checks
    指出在卸除散發者之前,是否要檢查相依物件。no_checksbit,預設值是 0。

    如果是 0sp_dropdistributor 會檢查確認除了散發者,所有發行和散發物件也都已經卸除。

    如果是 1sp_dropdistributor 會在解除安裝散發者之前,先卸除發行和散發物件。

  • [@ignore_distributor=] ignore_distributor
    指出是否在未連接到散發者的情況之下,執行這個預存程序。ignore_distributorbit,預設值是 0

    如果是 0sp_dropdistributor 會連接到散發者,且會移除所有複寫物件。如果 sp_dropdistributor 無法連接到散發者,預存程序便會失敗。

    如果是 1,便不會連接到散發者,也不會移除複寫物件。如果在解除安裝散發者,或散發者已永久離線,便使用這個項目。在未來重新安裝散發者之前,不會移除這個發行者在散發者的物件。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_dropdistributor 用於所有類型的複寫中。

如果伺服器有其他發行者或散發物件,除非 @no_checks 設為 1,否則,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

權限

只有系統管理員 (sysadmin) 固定伺服器角色的成員,才能夠執行 sp_dropdistributor