0

When doing the First Synchronization in Merge Replication, I'm having this error:

"Cannot delete table 'dbo.eqp_Equipment' because it is being referenced by a FOREIGN KEY constraint. (Source: MSSQLServer, Error number: 4712)"

Then I changed the "Action if name is in use" to "Truncate all data in the existing object", then I had the same issue:

"Cannot truncate table 'dbo.eqp_Equipment' because it is being referenced by a FOREIGN KEY constraint. (Source: MSSQLServer, Error number: 4712)"

How can I solve this problem?

Alexandre_Almeida
  • 131
  • 1
  • 3
  • 10

1 Answers1

1

Merge replication does not guarantee transactional consistency, nor do they guarantee changes are applied in the order it was received. ie on a subscriber, a child table could be updated before the parent. You have a couple options:

  1. Mark the foreign keys on the subscriber "NOT FOR REPLICATION". This tells SQL Server to ignore FK constraints for Replication.
  2. Specify a processing order for the merge articles
Greg
  • 3,861
  • 3
  • 23
  • 58