Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Violation of PRIMARY KEY constraint during Merge Replication

$
0
0

I have two identical SQL Server 2005 databases (MYDB_Pub, MYDB_Sub1) where the merge replication was configured and it works fine.

Recently we upgraded to SQL Server 2014. To test the replication functionality on the new SQL Server I followed the below steps:

  • Backup the MYDB_Pub on the SQL Server 2005.
  • Restore the MYDB_Pub on the SQL Server 2014 with the same name.
  • Restore the same MYDB_Pub on the SQL Server 2014 with name 'MYDB_Sub1'.
  • Configure Merge Replication on a single table 'Country'.

Now when I run the replication process, I get the following error message:

enter image description here

The table structure is given below:

CREATE TABLE [dbo].[Country](
    [CountryId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
    [Code] [char](2) NOT NULL,  
    [CountryName] [varchar](50) NOT NULL,   
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Country_rowguid]  DEFAULT (newsequentialid()) 
)
GO
ALTER TABLE [dbo].[Country]  WITH NOCHECK ADD  CONSTRAINT [repl_identity_range_BEB70305_9154_4BBE_B898_61681A047BA2] CHECK NOT FOR REPLICATION (([CountryId]>(112251) AND [CountryId]<=(113251) OR [CountryId]>(113251) AND [CountryId]<=(114251)))
GO
ALTER TABLE [dbo].[Country] CHECK CONSTRAINT [repl_identity_range_BEB70305_9154_4BBE_B898_61681A047BA2]
GO

Please note that [rowguid] column was already there in the database before defining the replication. Country table in both publisher and subscriber have similar data as publisher and subscriber were restored from same file.

To configure the replication I used the instruction provided in this article.

Subscription properties and Article properties of Country table are shown in the below screenshots

enter image description here

enter image description here

I have tried to find the solution for this error but nothing helped. I must make it clear that I am not a DBA and its the first time I am playing with replication on SQL Server. I would really appreciate any help.


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>