방법: 밀어넣기 구독 삭제(복제 Transact-SQL 프로그래밍)

밀어넣기 구독은 복제 저장 프로시저를 사용하여 프로그래밍 방식으로 삭제할 수 있습니다. 사용되는 저장 프로시저는 구독이 속한 게시 유형에 따라 달라집니다.

스냅숏 또는 트랜잭션 게시에 대한 밀어넣기 구독을 삭제하려면

  1. 게시 데이터베이스의 게시자에서 sp_dropsubscription(Transact-SQL)을 실행합니다. @publication@subscriber를 지정합니다. @articleall 값을 지정합니다. (옵션) 배포자에 액세스할 수 없으면 @ignore_distributor에 대해 값 1을 지정하여 배포자에서 관련 개체를 제거하지 않고 구독을 삭제합니다.

  2. 구독 데이터베이스의 구독자에서 sp_subscription_cleanup(Transact-SQL)을 실행하여 구독 데이터베이스의 복제 메타데이터를 제거합니다.

병합 게시에 대한 밀어내기 구독을 삭제하려면

  1. 게시자에서 @publication, @subscriber@subscriber_db를 지정하고 sp_dropmergesubscription(Transact-SQL)을 실행합니다. (옵션) 배포자에 액세스할 수 없으면 @ignore_distributor에 대해 값 1을 지정하여 배포자에서 관련 개체를 제거하지 않고 구독을 삭제합니다.

  2. 구독 데이터베이스의 구독자에서 sp_mergesubscription_cleanup(Transact-SQL)을 실행합니다. @publisher, @publisher_db@publication을 지정합니다. 이렇게 하면 구독 데이터베이스에서 병합 메타데이터가 제거됩니다.

이 예에서는 트랜잭션 게시에 대한 밀어넣기 구독을 삭제합니다.

-- 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".

-- This batch is executed at the Publisher to remove 
-- a pull or push subscription to a transactional publication.
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
SET @publication = N'AdvWorksProductTran';
SET @subscriber = $(SubServer);

USE [AdventureWorks2008R2;]
EXEC sp_dropsubscription 
  @publication = @publication, 
  @article = N'all',
  @subscriber = @subscriber;
GO

이 예에서는 병합 게시에 대한 밀어넣기 구독을 삭제합니다.

-- 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".

-- This batch is executed at the Publisher to remove 
-- a pull or push subscription to a merge publication.
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
DECLARE @subscriptionDB AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @subscriber = $(SubServer);
SET @subscriptionDB = N'AdventureWorks2008R2Replica';

USE [AdventureWorks2008R2]
EXEC sp_dropmergesubscription 
  @publication = @publication, 
  @subscriber = @subscriber, 
  @subscriber_db = @subscriptionDB;
GO