sp_removedbreplication (Transact-SQL)sp_removedbreplication (Transact-SQL)

适用对象: yesSQL ServeryesAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

此存储过程将删除 SQL Server 发布服务器实例的发布数据库上或 SQL Server 订阅服务器实例的订阅数据库上的所有复制对象。This stored procedure removes all replication objects on the publication database on the Publisher instance of SQL Server or on the subscription database on the Subscriber instance of SQL Server. 在相应的数据库中执行,或如果是在另一个数据库上下文的同一个实例上执行,请指定应删除复制对象的数据库。Execute in the appropriate database, or if the execution is in the context of another database on the same instance, specify the database where the replication objects should be removed. 此过程不会从其他数据库(例如,分发数据库)中删除对象。This procedure does not remove objects from other databases, such as the distribution database.

备注

只有当其他删除复制对象的方法都失败后,才应当使用此过程。This procedure should be used only if other methods of removing replication objects have failed.

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

语法Syntax

  
sp_removedbreplication [ [ @dbname = ] 'dbname' ]  
    [ , [ @type = ] type ]   

参数Arguments

[ @dbname = ] 'dbname' 是数据库的名称。[ @dbname = ] 'dbname' Is the name of the database. dbname 的数据类型为 sysname,默认值为 NULL。dbname is sysname, with a default value of NULL. 此参数值为 NULL 时,将使用当前数据库。When NULL, the current database will be used.

[ @type = ] type 是的复制的数据库内要被删除的对象的类型。[ @type = ] type Is the type of replication for which database objects are being removed. 类型nvarchar(5) 可以是下列值之一。type is nvarchar(5) and can be one of the following values.

trantran 删除事务复制发布对象。Removes transactional replication publishing objects.
合并merge 删除合并复制发布对象。Removes merge replication publishing objects.
同时(默认值)both (default) 删除所有复制发布对象。Removes all replication publishing objects.

返回代码值Return Code Values

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

备注Remarks

sp_removedbreplication用于所有类型的复制。sp_removedbreplication is used in all types of replication.

sp_removedbreplication还原复制的数据库,无需还原没有复制对象时非常有用。sp_removedbreplication is useful when restoring a replicated database that has no replication objects needing to be restored.

sp_removedbreplication不能使用针对数据库被标记为只读的。sp_removedbreplication cannot be used against a database that is marked as read-only.

示例Example

-- Remove replication objects from the subscription database on MYSUB.
DECLARE @subscriptionDB AS sysname
SET @subscriptionDB = N'AdventureWorks2012Replica'

-- Remove replication objects from a subscription database (if necessary).
USE master
EXEC sp_removedbreplication @subscriptionDB
GO

权限Permissions

只有的成员sysadmin固定的服务器角色可以执行sp_removedbreplicationOnly members of the sysadmin fixed server role can execute sp_removedbreplication.

示例Example

-- Remove replication objects from the subscription database on MYSUB.  
DECLARE @subscriptionDB AS sysname  
SET @subscriptionDB = N'AdventureWorksReplica'  
  
-- Remove replication objects from a subscription database (if necessary).  
USE master  
EXEC sp_removedbreplication @subscriptionDB  
GO  
  

请参阅See Also

禁用发布和分发 Disable Publishing and Distribution
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)