sp_dropmergearticle (Transact-SQL)
SQL Server 2012
Removes an article from a merge publication. This stored procedure is executed at the Publisher on the publication database.
sp_dropmergearticle [ @publication= ] 'publication'
, [ @article= ] 'article'
[ , [ @ignore_distributor= ] ignore_distributor
[ , [ @reserved= ] reserved
[ , [ @force_invalidate_snapshot= ] force_invalidate_snapshot ]
[ , [ @force_reinit_subscription = ] force_reinit_subscription ]
[ , [ @ignore_merge_metadata = ] ignore_merge_metadata ]
sp_dropmergearticle is used in merge replication. For more information about dropping articles, see Add Articles to and Drop Articles from Existing Publications.
Executing sp_dropmergearticle to drop an article from a publication does not remove the object from the publication database or the corresponding object from the subscription database. Use DROP <object> to remove these objects manually if necessary.
DECLARE @publication AS sysname; DECLARE @table1 AS sysname; DECLARE @table2 AS sysname; DECLARE @table3 AS sysname; DECLARE @salesschema AS sysname; DECLARE @hrschema AS sysname; DECLARE @filterclause AS nvarchar(1000); SET @publication = N'AdvWorksSalesOrdersMerge'; SET @table1 = N'Employee'; SET @table2 = N'SalesOrderHeader'; SET @table3 = N'SalesOrderDetail'; SET @salesschema = N'Sales'; SET @hrschema = N'HumanResources'; SET @filterclause = N'Employee.LoginID = HOST_NAME()'; -- Drop the merge join filter between SalesOrderHeader and SalesOrderDetail. EXEC sp_dropmergefilter @publication = @publication, @article = @table3, @filtername = N'SalesOrderDetail_SalesOrderHeader', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1; -- Drops the merge join filter between Employee and SalesOrderHeader. EXEC sp_dropmergefilter @publication = @publication, @article = @table2, @filtername = N'SalesOrderHeader_Employee', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1; -- Drops the article for the SalesOrderDetail table. EXEC sp_dropmergearticle @publication = @publication, @article = @table3, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1; -- Drops the article for the SalesOrderHeader table. EXEC sp_dropmergearticle @publication = @publication, @article = @table2, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1; -- Drops the article for the Employee table. EXEC sp_dropmergearticle @publication = @publication, @article = @table1, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1; GO
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