Saturday, February 25, 2012

Publication contains references to foreign keys outside the publication.

At the moment I have a publication with some tables(not all tables in the
db). But the tables inside the publications contains references to foreign
keys to tables outside of the publication. How do I create new subscription
disregarding the Foreign keys constraint to tables outside of the
publication in the same database? How do I simply create the new
subscription disregarding the Foreign Keys references? What's the best way
to switch off foreign keys while creating the subscription and then turn it
back on after subscription created?
Joe,
in the table article properties, there is an option to "Include Declared
Referential Integrity". By default this is off. If it is selected, then
there will be another script created when the initial snapshot is created
during initialization. This script will contain the foreign keys only if all
the related tables are in the same publication. So either way, the FKs
shouldn't be created in your case. If you want to add foreign keys
afterwards you have a few options, eg you could add a postscript, or you
could use sp_addscriptexec.
Regards,
Paul Ibison

No comments:

Post a Comment