如何实现中央订阅者模型复制?
我有问题请帮助我。
假设我有三个数据库 Db1、Db2、DbCenter 和 tbl_country 存在于所有数据库中。
Db1中的tbl_country有以下记录:
tbl_country
Id Name
1 US
2 Germany
Db2中的tbl_country有以下记录:
tbl_country
Id Name
1 Australia
2 Italy
并且Db1和Db2中的tbl_country的合并记录必须在DbCenter中合并,
因此DbCenter中的tbl_country有以下条目:
tbl_country
Id Name
1 Us
2 Germany
3 Australia
4 Italy
所有表中的“id”列为主键和身份。
如何在DbCenter的tbl_country最后添加两条Db1和Db2的记录?
我正在使用事务复制。将 Db1 和 Db2 设置为发布者,并将 DbCenter 指定为订阅者,并在 Db2 的文章属性中将“使用名称时的操作”操作设置为“保持现有对象不变”,但它会删除 DbCenter 中的记录,并在以下情况下用新记录替换它们: “id”列中的记录是相同的。 Db1和Db2是Sql server 2000版本,Db3是Sql server 2008R2。
I have a problem please help me.
suppose I have three databases Db1,Db2,DbCenter and tbl_country exists in all of databases.
tbl_country in Db1 has following records:
tbl_country
Id Name
1 US
2 Germany
tbl_country in Db2 has following records:
tbl_country
Id Name
1 Australia
2 Italy
and the merged records of tbl_country in Db1 and Db2 must be merged in DbCenter,
so tbl_country in DbCenter has following entries:
tbl_country
Id Name
1 Us
2 Germany
3 Australia
4 Italy
the "id" column in all of tables is primary key and identity.
What should I do to the records of two Db1 and Db2 be added in the last of tbl_country of DbCenter.
I'm using transactional replication. set Db1 and Db2 as publishers and specify DbCenter as subscriber and in article properties of Db2 set the action of "Action if name in use" to "Keep existing object unchanged" but it delete the records in DbCenter and substitute them with new ones when the records in "id" column are the same.
Db1 and Db2 are Sql server 2000 version and Db3 is Sql server 2008R2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
维护 DbCenter 数据库中的原始键值以及指定其来自哪个数据库的元数据。然后生成将用作 PK 的代理密钥。这样,您就可以拥有每个国家/地区记录的唯一引用以及链接回源信息的方法。
例如:-
Maintain the original key values in the DbCenter database, along with metadata that specifies which database it came from. Then generate a surrogate key that will be used as the PK. That way you both have unique references for each Country records and a way to link back to the source information.
For example:-
如果 Db1 和 Db2 有重叠的主键值,我认为没有任何方法可以做到这一点。如果您可以控制架构并且能够更改它,您可能希望将主键更改为 uniqueidentifier 类型(而不是 int),以保证全局唯一。
If Db1 and Db2 have overlapping primary key values, I don't think there is any way to do this. If you have control over the schema, and are able to change it, you might want to change the primary keys to the uniqueidentifier type (instead of int) which is guaranteed to be globally unique.