Foreign key issues while applying a snapshot in SQL Server merge replication

This article will review specific SQL Server merge replication issues related to foreign keys and schema. .SQL Server Training.



Problem

We have merge replication configured on a database to replicate data to different subscribers. Database Training. While applying the initial snapshot to subscribers the merge agent fails due to foreign keys on non-replicating tables.SQL Server Training. In this article we’ll see how we solved this using pre and post snapshot scripts. Database Training.

Solution

There are few tables which are added to merge replication. SQL Server Training. These tables have primary key and are being referenced by foreign keys which were created on non-replicating tables. Database Training. Now while applying the initial snapshot on subscribers, the merge agent tries to drop and re-create the table which throws error “The schema script could not be propagated to the subscriber.SQL Server Training. Could not drop object ‘dbo.tablename’ because it is referenced by a FOREIGN KEY constraint”. Database Training.

ADDRESS :

LOCATION :

701, Linden, Rosalie Complex Khadakpada, Kalyan (W) Mumbai, Maharashtra 421301)

CONTACT US :

+919322846017  &   +919867493019

EMAIL: 

QUICK LINKS :

SUBSCRIBE HERE :

Don’t Miss a Lecture. Subscribe Today. 

telegram-512.png

© 2019 DBA Trainings. Proudly Managed By Pearl Organisation

  • Grey LinkedIn Icon
  • Grey YouTube Icon
  • Grey Twitter Icon
  • Grey Facebook Icon