sp_reinitmergesubscription (Transact-SQL)
SQL Server 2008 R2
Marks a merge subscription for reinitialization the next time the Merge Agent runs. This stored procedure is executed at the Publisher in the publication database.
sp_reinitmergesubscription is used in merge replication.
sp_reinitmergesubscription can be called from the Publisher to reinitialize merge subscriptions. We recommend re-running the Snapshot Agent as well.
If you add, drop, or change a parameterized filter, pending changes at the Subscriber cannot be uploaded to the Publisher during reinitialization. If you want to upload pending changes, synchronize all subscriptions before changing the filter.
-- 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".
DECLARE @subscriptionDB AS sysname;
DECLARE @publication AS sysname;
SET @subscriptionDB = N'AdventureWorks2008R2Replica';
SET @publication = N'AdvWorksSalesOrdersMerge';
USE [AdventureWorks2008R2Replica]
-- Execute at the Publisher to reinitialize the push subscription.
-- Pending changes at the Subscrber are lost.
EXEC sp_reinitmergesubscription
@subscriber = $(SubServer),
@subscriber_db = @subscriptionDB,
@publication = @publication,
@upload_first = N'false';
GO
-- Start the Merge Agent.
-- 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".
DECLARE @subscriptionDB AS sysname;
DECLARE @publication AS sysname;
SET @subscriptionDB = N'AdventureWorks2008R2Replica';
SET @publication = N'AdvWorksSalesOrdersMerge';
USE [AdventureWorks2008R2Replica]
-- Execute at the Publisher to reinitialize the push subscription,
-- and upload pending changes at the Subscriber.
EXEC sp_reinitmergesubscription
@subscriber = $(SubServer),
@subscriber_db = @subscriptionDB,
@publication = @publication,
@upload_first = N'true';
GO
-- Start the Merge Agent.
