top of page
Writer's pictureDba Trainings

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.

66 views0 comments

Comments


bottom of page