Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Trans. Replication for Table with Foreign Key?

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2014-05-29 : 19:38:23
Hi all,
(I know there is a forum specifically for Replication but it seems to not be very active)
My question is: Is it possible to use Transactional Replication on a table that has a Foreign Key? It has a Primary key but also a couple of foreign keys. (This is 2008 R2)
Thanks, Jack

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-05-29 : 19:41:29
Yes. We don't copy the foreign keys to the subscriber, but you can if you want to. The only issue if you have multiple publications sending the data to the same subscriber, and the related tables are split up amongst those publications. You could run into FK issues in that case. You get around that by not adding the FKs to the subscriber, though this could cause "bad" data. The way around the entire thing is to have one publication for a set of related tables.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2014-05-29 : 21:36:02
Thank you, thank you Tara!
This is wonderful news. Obviously, I have not tried it yet. I will have only 1 publication and 1 subscriber for these tables. Can't wait to try this tomorrow!
Jack
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-05-29 : 22:27:01


Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -