开发者

SQL Server Replication not replicating Foreign Keys

开发者 https://www.devze.com 2023-04-08 18:17 出处:网络
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开发者_如何学J

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:

  1. Should replication be copying these foreign keys by default?
  2. If not, how can I get them to replicate?
  3. 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'.

0

精彩评论

暂无评论...
验证码 换一张
取 消