sp_dropdistpublisher (Transact-SQL)

删除分发发布服务器。 此存储过程在分发服务器的任何数据库中执行。

主题链接图标Transact-SQL 语法约定

语法

sp_dropdistpublisher [ @publisher = ] 'publisher'
    [ , [ @no_checks = ] no_checks ]
    [ , [ @ignore_distributor = ] ignore_distributor ]

参数

  • [ @publisher= ] 'publisher'
    要删除的发布服务器。publisher 的数据类型为 sysname,无默认值。

  • [ @no_checks= ] no_checks
    指定 sp_dropdistpublisher 是否进行检查以确保发布服务器已卸载用作分发服务器的服务器。no_checks 的数据类型为 bit,默认值为 0

    如果为 0,复制将验证远程发布服务器是否已卸载了作为分发服务器的本地服务器。 如果发布服务器是本地服务器,则复制将验证没有发布对象或分发对象保留在本地服务器上。

    如果为 1,则即使无法到达远程发布服务器,也将删除与分发发布服务器关联的所有复制对象。 执行该操作后,远程发布服务器必须使用 sp_dropdistributor(且 @ignore_distributor = 1)卸载复制。

  • [ @ignore_distributor= ] ignore_distributor
    指定删除发布服务器时是否将分发对象保留在分发服务器中。ignore_distributor 的数据类型为 bit,可以是下列值之一:

    1 = 保留分发服务器上属于 publisher 的分发对象。

    0 = 清除分发服务器上属于 publisher 的分发对象。

返回代码值

0(成功)或 1(失败)

注释

sp_dropdistpublisher 用于所有类型的复制。

如果无法删除 Oracle 发布服务器,sp_dropdistpublisher 将返回一个错误,并删除该发布服务器的分发服务器对象。

示例

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

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