sql server - Violation of PRIMARY KEY constraint during Merge Replication -
i have 2 identical sql server 2005 databases (mydb_pub, mydb_sub1) merge replication configured , works fine.
recently upgraded sql server 2014. test replication functionality on new sql server followed below steps:
- backup mydb_pub on sql server 2005.
- restore mydb_pub on sql server 2014 same name.
- restore same mydb_pub on sql server 2014 name 'mydb_sub1'.
- configure merge replication on single table 'country'.
now when run replication process, following error message:
the table structure given below:
create table [dbo].[country]( [countryid] [int] identity(1,1) not 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] nocheck add constraint [repl_identity_range_beb70305_9154_4bbe_b898_61681a047ba2] check not replication (([countryid]>(112251) , [countryid]<=(113251) or [countryid]>(113251) , [countryid]<=(114251))) go alter table [dbo].[country] check constraint [repl_identity_range_beb70305_9154_4bbe_b898_61681a047ba2] go
please note [rowguid]
column there in database before defining replication. country
table in both publisher , subscriber have similar data publisher , subscriber restored same file.
to configure replication used instruction provided in this article.
subscription properties , article properties of country
table shown in below screenshots
i have tried find solution error nothing helped. must make clear not dba , first time playing replication on sql server. appreciate help.
the reason getting error because table exists on subscriber, , populated, , initialization trying re-populate table data publisher. doing because article property says "action if name in use = keep existing object unchanged". believe default "drop table , recreate object" or that, means when synchronize initialization, drop table @ subscriber, populate it. avoid error above, since table @ subscriber empty before populated.
so need decide, if need existing data @ subscriber, or if during initialization, can let merge replication drop objects, , repopulate based off snapshot publisher.
Comments
Post a Comment