用于复制的 T-SQL 查询文章

发布于 2024-10-09 19:10:39 字数 51 浏览 1 评论 0原文

有谁知道我可以运行一个查询来告诉我目标数据库中的哪些文章(如果有)与事务复制发布相关联?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

旧人哭 2024-10-16 19:10:39

对于那些需要快速片段的人...

SELECT 
  msp.publication AS PublicationName,
  msa.publisher_db AS DatabaseName,
  msa.article AS ArticleName,
  msa.source_owner AS SchemaName,
  msa.source_object AS TableName
FROM distribution.dbo.MSarticles msa
JOIN distribution.dbo.MSpublications msp ON msa.publication_id = msp.publication_id
ORDER BY 
  msp.publication, 
  msa.article

For those needing a quick snippet...

SELECT 
  msp.publication AS PublicationName,
  msa.publisher_db AS DatabaseName,
  msa.article AS ArticleName,
  msa.source_owner AS SchemaName,
  msa.source_object AS TableName
FROM distribution.dbo.MSarticles msa
JOIN distribution.dbo.MSpublications msp ON msa.publication_id = msp.publication_id
ORDER BY 
  msp.publication, 
  msa.article
少跟Wǒ拽 2024-10-16 19:10:39

以下是与 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.

紙鸢 2024-10-16 19:10:39

查看 syspublications 以查看发布者数据库上设置的发布列表。希望您能够看到其中包含标识您感兴趣的订户数据库的描述。记下您感兴趣的出版物的 pubid:

select * from syspublications

然后查看 sysarticles 以查看哪些表实际复制到该端点:

select * from sysarticles where pubid = 3

这需要在发布者数据库上运行,而不是在订阅者数据库上运行。

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:

select * from syspublications

Then look in sysarticles to see which tables are actually replicated to that end point:

select * from sysarticles where pubid = 3

This needs to run on the publisher database, not the subscriber database.

少钕鈤記 2024-10-16 19:10:39
EXEC sp_helparticle @publication='{your_publication_name}'

显示有关文章的信息。此存储过程在发布服务器上的发布数据库上执行。对于 Oracle 发布服务器,此存储过程在分发服务器上的任何数据库上执行。

请参阅 https://msdn.microsoft.com/en-us/library/ms187741。 ASPX

EXEC sp_helparticle @publication='{your_publication_name}'

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

泪痕残 2024-10-16 19:10:39

对于那些希望列出 MERGE REPLICATION 文章的人,以下代码片段可能会有所帮助:

SELECT 
    p.Name,
    a.* 
FROM [Publisher_DB_NAME].dbo.sysmergepublications p
JOIN [Publisher_DB_NAME].dbo.sysmergearticles a on p.pubid=a.pubid

请注意,在发布者数据库中查询 sysmergepublicationssysmergearticles 表,因为 <在我使用 SQL Server 2008 R2 的案例中,其他答案中提到的 distribution DB 中的 code>MSpublications 和 MSarticles 表没有合并复制文章的记录。

希望这可以帮助那些使用合并复制并最终在这里进行 SO 搜索的人。

For those looking to list MERGE REPLICATION articles the following snippet may help:

SELECT 
    p.Name,
    a.* 
FROM [Publisher_DB_NAME].dbo.sysmergepublications p
JOIN [Publisher_DB_NAME].dbo.sysmergearticles a on p.pubid=a.pubid

Note, that sysmergepublications and sysmergearticles tables are queried in the Publisher DB because MSpublications and MSarticles tables in distribution 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.

╄→承喏 2024-10-16 19:10:39
SELECT 
    p.Name,
    a.* 
FROM dbo.sysmergepublications p
JOIN dbo.[sysmergeextendedarticlesview] a on p.pubid=a.pubid 

您也可以使用它来获取视图列表

SELECT 
    p.Name,
    a.* 
FROM dbo.sysmergepublications p
JOIN dbo.[sysmergeextendedarticlesview] a on p.pubid=a.pubid 

Also you can use this to get the view list

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文