다음을 통해 공유


How to: Delete an Article (Replication Transact-SQL Programming)

Articles can be deleted programmatically using replication stored procedures. The stored procedures that you use depend on the type of publication to which the article belongs. For information about the conditions under which articles can be dropped and whether dropping an article requires a new snapshot or the reinitialization of subscriptions, see 기존 게시에 대한 아티클 추가 및 삭제.

To delete an article from a snapshot or transactional publication

  1. Execute sp_droparticle(Transact-SQL) to delete an article, specified by @article, from a publication, specified by @publication. Specify a value of 1 for @force_invalidate_snapshot.

  2. (Optional) To remove the published object from the database entirely, execute the DROP <objectname> command at the Publisher on the publication database.

To delete an article from a merge publication

  1. Execute sp_dropmergearticle(Transact-SQL) to delete an article, specified by @article, from a publication, specified by @publication. If necessary, specify a value of 1 for @force_invalidate_snapshot and a value of 1 for @force_reinit_subscription.

  2. (Optional) To remove the published object from the database entirely, execute the DROP <objectname> command at the Publisher on the publication database.

The following example deletes an article from a transactional publication. Because this change invalidates the existing snapshot, a value of 1 is specified for the @force_invalidate_snapshot parameter.

DECLARE @publication AS sysname;
DECLARE @article AS sysname;
SET @publication = N'AdvWorksProductTran'; 
SET @article = N'Product'; 

-- Drop the transactional article.
USE [AdventureWorks]
EXEC sp_droparticle 
  @publication = @publication, 
  @article = @article,
  @force_invalidate_snapshot = 1;
GO

The following example deletes two articles from a merge publication. Because these changes invalidate the existing snapshot, a value of 1 is specified for the @force_invalidate_snapshot parameter.

DECLARE @publication AS sysname;
DECLARE @article1 AS sysname;
DECLARE @article2 AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @article1 = N'SalesOrderDetail'; 
SET @article2 = N'SalesOrderHeader'; 

-- Remove articles from a merge publication.
USE [AdventureWorks]
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @article1,
  @force_invalidate_snapshot = 1;
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @article2,
  @force_invalidate_snapshot = 1;
GO

참고 항목

작업

How to: Delete an Article (RMO Programming)

개념

Programming Replication Using System Stored Procedures

관련 자료

기존 게시에 대한 아티클 추가 및 삭제

도움말 및 정보

SQL Server 2005 지원 받기