2

I have a Publisher and a Subscriber, Sometimes they insert the same row at the same time, when I run the JOB for Merge Replication I have a PRIMARY KEY violation.

I have a UK (Col1, Col2), a PK (uniqueidentifier) and the MERGE REPLICATION adds a ROWGUID. The problem is that when they add at the same time (but not connected one to another), they generate the same UK, but the ROWGUID is different. I need to use the UK instead of ROWGUID. I'm NOT using IDENTITY column.

shA.t
  • 16,580
  • 5
  • 54
  • 111
Alexandre_Almeida
  • 131
  • 1
  • 3
  • 10

1 Answers1

0

This is by design. Conflicts may occur.

I think you should redesign your database in order to not run into such conflicts. For example if you have identity columns then reseed them on subscribers in order to get different ranges. Or may be add third column to UK with SubscriberID. This is the idea.

Giorgi Nakeuri
  • 35,155
  • 8
  • 47
  • 75
  • I can't redesign my tables and I'm not using identity column. – Alexandre_Almeida Apr 20 '15 at 12:11
  • You will need to redesign your tables to avoid conflicts. – Brandon Williams Apr 20 '15 at 16:01
  • But i can't redesign, I have 113 tables linked. I've read that i can't solve PRIMARY KEY violation whit the Article Resolver. All I need is set Publisher/Subscriber to win based on datetime. At the resolver I can choose a 'custom resolver' to solve my problem... but it won't work whit PK violation. – Alexandre_Almeida Apr 20 '15 at 22:28