用于复制的 T-SQL 查询文章
有谁知道我可以运行一个查询来告诉我目标数据库中的哪些文章(如果有)与事务复制发布相关联?
Does anyone know of a query I could run that would tell me what articles, if any, in a target database, are associated with a transactional replication publication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对于那些需要快速片段的人...
For those needing a quick snippet...
以下是与 SQL Server 复制相关的所有表
http://msdn.microsoft.com/ en-us/library/ms179855.aspx
向下滚动到“订阅数据库中的复制表”部分,您将找到发布、订阅、架构、文章和列的表。
Here are all tables involved with SQL Server Replication
http://msdn.microsoft.com/en-us/library/ms179855.aspx
Scroll down to the section for "Replication Tables in the Subscription Database" and you will find the tables for publications, subscriptions, schemas, articles and columns.
查看 syspublications 以查看发布者数据库上设置的发布列表。希望您能够看到其中包含标识您感兴趣的订户数据库的描述。记下您感兴趣的出版物的 pubid:
然后查看 sysarticles 以查看哪些表实际复制到该端点:
这需要在发布者数据库上运行,而不是在订阅者数据库上运行。
Look in syspublications to see a list of the publications set up on the publisher database. Hopefully you will be able to see one with a description that identifies the subscriber database you are interested in. Take note of the pubid of the publication you are interested in:
Then look in sysarticles to see which tables are actually replicated to that end point:
This needs to run on the publisher database, not the subscriber database.
显示有关文章的信息。此存储过程在发布服务器上的发布数据库上执行。对于 Oracle 发布服务器,此存储过程在分发服务器上的任何数据库上执行。
请参阅 https://msdn.microsoft.com/en-us/library/ms187741。 ASPX
Displays information about an article. This stored procedure is executed at the Publisher on the publication database. For Oracle Publishers, this stored procedure is executed at the Distributor on any database.
See https://msdn.microsoft.com/en-us/library/ms187741.aspx
对于那些希望列出 MERGE REPLICATION 文章的人,以下代码片段可能会有所帮助:
请注意,在发布者数据库中查询
sysmergepublications
和sysmergearticles
表,因为 <在我使用 SQL Server 2008 R2 的案例中,其他答案中提到的distribution
DB 中的 code>MSpublications 和MSarticles
表没有合并复制文章的记录。希望这可以帮助那些使用合并复制并最终在这里进行 SO 搜索的人。
For those looking to list MERGE REPLICATION articles the following snippet may help:
Note, that
sysmergepublications
andsysmergearticles
tables are queried in the Publisher DB becauseMSpublications
andMSarticles
tables indistribution
DB mentioned in other answers in my case with SQL Server 2008 R2 had no records for merge replication articles.Hope this helps someone working with merge replication who ended up here with SO search.
您也可以使用它来获取视图列表
Also you can use this to get the view list