Cleaning replication tables before snapshot applied to subscriber
-
03-03-2021 - |
Question
We have a snapshot replication setup.
In some cases (like previous replications failed etc), some subscribers get the following error
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “<FK_constraint>”. The conflict occurred in database “”, table “”, column ‘’. (Source: MSSQLServer, Error number: 547)
I found out that executing following clean up SQL on the subscriber would solve the issue
delete dbo.MSsavedForeignKeys where constraint_name = N'<FK_constraint>'
Or simply, executing the above SQL without any where
clause to clean the dbo.MSsavedForeignKeys
table and all problems got fixed. But it was getting a problem when the number of subscribers increases.
What I wonder is,
- Is it safe to add this delete statement (without
where
clause) to pre-execution scripts to automatize the process? - Are there any other replication tables that could cause such problems and could be deleted with pre-execution scripts?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange