SQL Server Replication not replicating Foreign Keys
I am replicating several tables to a database on the same server as the source database.
Those tables have several foreign keys between them. When I look at the replicated tables, they d开发者_如何学JAVAo not have the foreign keys on them.
So, here are my questions:
- Should replication be copying these foreign keys by default?
- If not, how can I get them to replicate?
- If so, what would cause them to not replicate?
NOTE:
My source database has TableA
and TableB
. TableA
has a primary key of AId
. TableB
has a foreign key on that column. And I am doing a transactional replication of both TableA
and TableB
.
OK, I came across something, but it would depend on what type of replication you are using.
I am using transactional replcation. Find the publication you are using here,
(Management Studio) Replication -> Local Publications -> (Publication)
Right click the publication and select properties, then under articles right click 'Tables' and select the option 'Set Properties of All Table Articles'.
In there the first item is 'Copy foreign key constraints'.
Haven't tried it, but I expect it to work.
You can apply these settings per table too if you right click a single table and select the option 'Set Properties of This Table Article'.
精彩评论