SQL Server 2014 merge replication throws PRIMARY KEY violation during the initialization of Subscriber
Hi Folks,
I am using SQL Server 2014 SP1 to set up merge replication on Windows 2008. The databases (Publisher & Subscriber) are restored from the production back up of SQL Server 2005 publisher database.

The merge replication set up on SQL Server 2005 works fine. However when I set up the merge replication on SQL server 2014, I am getting the following error.
For new tables created in the Publisher & Subscriber, the replication works fine. The isssue occurs only for the existing tables with data.

Error messages:
The merge process was unable to deliver the snapshot to the Subscriber. If using Web synchronization, the merge process may have been unable to create or write to the message file. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
The process could not bulk copy into table '"dbo"."FiscalVisitType"'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20037)
Get help: http://help/MSSQL_REPL20037
Batch send failed (Source: MSSQLServer, Error number: 0)
Get help: http://help/0
Violation of PRIMARY KEY constraint 'PK_FiscalVisitType'. Cannot insert duplicate key in object 'dbo.FiscalVisitType'. The duplicate key value is (1). (Source: MSSQLServer, Error number: 2627)
Get help: http://help/2627
To obtain an error file with details on the errors encountered when initializing the subscribing table, execute the bcp command that appears below. Consult the BOL for more information on the bcp utility and its supported options. (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253
bcp "SIPG_Subscriber"."dbo"."FiscalVisitType" in "C:\Program Files\Microsoft SQL Server\MSSQL12.OGIS\MSSQL\ReplData\unc\PC39606-ORG-D-P$OGIS_SIPG_PUBLISHER_OGIS_PUBLICATION\20150624142806\FiscalVisitType_2.bcp" -e "errorfile" -t"<x$3>" -r"<,@g>" -m10000 -SPC39606-ORG-D-P\OGIS -T -w (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253

Please find attached the Publisher properties of the article.

Thanks in advance
Bisaac 
June 26th, 2015 10:23am

Hi Bisaac,

We cannot find your attached file, please attach it in this forum.

Based on your description, you restore Subscriber database from backup of SQL Server 2005 publisher database. How do you set the Action if name is in use option of the article properties? If you set it to Keep existing ,  the above error could occur when subscriber table has the same data during the initialization process.


To solve this error, please drop the replicated table on the subscriber, set the Action if name is in use to Drop existing in the article properties, then create the replicated table on the subscriber and bcp the snapshot data into the table. For more details, please review the following similar blog.

Initialization of Merge Replication subscriber fails with primary key violation
http://blogs.msdn.com/b/repltalk/archive/2012/07/30/initialization-of-merge-replication-subscriber-fails-with-primary-key-violation.aspx

Thanks,
Lydia Zhang

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2015 11:29pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics