sp_dropdistpublisher (Transact-SQL)sp_dropdistpublisher (Transact-SQL)

适用于: 是SQL Server 是Azure SQL 数据库(仅限托管实例)否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: YesSQL Server YesAzure SQL Database (Managed Instance only) NoAzure Synapse Analytics (SQL DW) NoParallel Data Warehouse

删除分发发布服务器。Drops a distribution Publisher. 此存储过程在分发服务器上的任何数据库中执行。This stored procedure is executed at the Distributor on any database.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

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

参数Arguments

[ @publisher = ] 'publisher'是要删除的发布服务器。[ @publisher = ] 'publisher' Is the Publisher to drop. 发布服务器sysname,无默认值。publisher is sysname, with no default.

[ @no_checks = ] no_checks指定sp_dropdistpublisher是否检查发布服务器是否已卸载服务器作为分发服务器。[ @no_checks = ] no_checks Specifies whether sp_dropdistpublisher checks that the Publisher has uninstalled the server as the Distributor. no_checksbit,默认值为0no_checks is bit, with a default of 0.

如果为0,则复制将验证远程发布服务器是否已卸载本地服务器作为分发服务器。If 0, replication verifies that the remote Publisher has uninstalled the local server as the Distributor. 如果发布服务器是本地服务器,则复制将验证没有发布对象或分发对象保留在本地服务器上。If the Publisher is local, replication verifies that there are no publication or distribution objects remaining on the local server.

如果为1,则即使无法访问远程发布服务器,也将删除与分发发布服务器关联的所有复制对象。If 1, all the replication objects associated with the distribution Publisher are dropped even if a remote Publisher cannot be reached. 执行此操作后,远程发布服务器必须使用** @ ignore_distributor**1 的sp_dropdistributor卸载复制 = 1After doing this, the remote Publisher must uninstall replication using sp_dropdistributor with @ignore_distributor = 1.

[ @ignore_distributor = ] ignore_distributor指定在删除发布服务器时是否将分发对象保留在分发服务器上。[ @ignore_distributor = ] ignore_distributor Specifies whether distribution objects are left at the Distributor when the Publisher is removed. ignore_distributorbit ,可以是下列值之一:ignore_distributor is bit and can be one of these values:

1 =发布服务器上保留的分发对象。1 = distribution objects belonging to the publisher remain at the Distributor.

0 = 在分发服务器上清理发布服务器的分发对象。0 = distribution objects for the publisher are cleaned-up at the Distributor.

返回代码值Return Code Values

0 (成功)或1 (失败)0 (success) or 1 (failure)

备注Remarks

sp_dropdistpublisher在所有类型的复制中使用。sp_dropdistpublisher is used in all types of replication.

删除 Oracle 发布服务器时,如果无法删除发布服务器sp_dropdistpublisher将返回错误,并且会删除发布服务器的分发服务器对象。When dropping an Oracle Publisher, if unable to drop the Publisher sp_dropdistpublisher returns an error and the Distributor objects for the Publisher are removed.

示例Example

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

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

权限Permissions

只有sysadmin固定服务器角色的成员才能sp_dropdistpublisher执行。Only members of the sysadmin fixed server role can execute sp_dropdistpublisher.

另请参阅See Also

禁用发布和分发 Disable Publishing and Distribution
sp_adddistpublisher (Transact-sql) sp_adddistpublisher (Transact-SQL)
sp_changedistpublisher (Transact-sql) sp_changedistpublisher (Transact-SQL)
sp_helpdistpublisher (Transact-sql) sp_helpdistpublisher (Transact-SQL)
复制存储过程 (Transact-SQL)Replication Stored Procedures (Transact-SQL)