SQL Server:订阅:如何知道表是否处于复制/订阅状态

发布于 2024-10-12 18:54:00 字数 60 浏览 3 评论 0原文

在SQL Server中,在“订阅端”,如何知道表是否处于复制/订阅状态?

有什么想法吗?

In SQL Server, on the "Subscription side", how can you know if a table is under replication/subscription?

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

眼泪淡了忧伤 2024-10-19 18:54:00

我不确定对此有一个简单的答案,并且我认为答案可能会根据复制类型而有所不同。我认为你可能必须依靠启发法来回答这个问题。

对于快照复制,我想不出任何会泄露游戏信息的东西。显然,复制表的存在(例如 MSreplication_objects< /a>) 告诉您复制正在数据库内发生,但据我所知,没有任何有关表的具体线索。

对于事务复制(非更新),您可以通过 MSreplication_objects (这将列出一些存储过程),然后使用 sys.sql_dependency 查找与这些相关的表

对于事务复制(更新),您可以查看 MSsubscription_articles (或查找表中是否存在订阅更新触发器)

对于合并复制,您可以查看 < a href="http://technet.microsoft.com/en-us/library/ms189825.aspx" rel="nofollow">sysmergearticles,但您还必须查看 sysmergesubscriptions 以确定您re 在订阅方面。

I'm not sure there's a simple answer to this, and I think the answers may vary based on the type of replication. I think you may have to rely on heuristics to answer it.

For snapshot replication, I'm unable to think of anything that would give the game away. Obviously, the presence of the replication tables (e.g. MSreplication_objects) tells you that replication is occurring within the database, but there aren't any specific clues about tables, so far as I'm aware.

For transactional replication (non updating), you may be able to go via MSreplication_objects (which will list some stored procs) and then use sys.sql_dependencies to locate the tables that these relate to

For transaction replication (updating), you can look in MSsubscription_articles (or look for the presence of the subscription updating triggers against the table)

For merge replication, you can look in sysmergearticles, but you'd also have to look in sysmergesubscriptions to determine that you're on the subscription side.

多像笑话 2024-10-19 18:54:00

转至订阅者数据库检查表 dbo.MSreplication_subscriptions。如果数据库是subscriber,您将找到此表。另外,要查找文章,请在 subscribed 数据库中使用它

SELECT publisher,Publisher_Db,publication,article
FROM dbo.MSreplication_objects

Go to the subscriber database check for the table dbo.MSreplication_subscriptions. If the database is subscriber, you will find this table. Also, to find out articles use this in the subscribed database

SELECT publisher,Publisher_Db,publication,article
FROM dbo.MSreplication_objects
诠释孤独 2024-10-19 18:54:00

我使用非信徒达米安的想法(+1)来生成对我有用的代码

SELECT DISTINCT
    ot.object_id
    ,ot.schema_id
    ,r.publisher
    ,r.publisher_db
    ,r.publication
    ,r.article
FROM 
    dbo.MSreplication_objects R
        INNER JOIN sys.objects so ON r.object_name = so.name AND so.type = 'P' --stored procedures
        INNER JOIN sys.sql_dependencies dp ON so.object_id = dp.object_id
        INNER JOIN sys.objects ot ON dp.referenced_major_id = ot.object_id  --objects
                                AND r.article = ot.name

I used Damien the Unbeliever's idea (+1) to produce this code that worked for me

SELECT DISTINCT
    ot.object_id
    ,ot.schema_id
    ,r.publisher
    ,r.publisher_db
    ,r.publication
    ,r.article
FROM 
    dbo.MSreplication_objects R
        INNER JOIN sys.objects so ON r.object_name = so.name AND so.type = 'P' --stored procedures
        INNER JOIN sys.sql_dependencies dp ON so.object_id = dp.object_id
        INNER JOIN sys.objects ot ON dp.referenced_major_id = ot.object_id  --objects
                                AND r.article = ot.name
飘然心甜 2024-10-19 18:54:00

最简单的方法是创建一个到主服务器的链接服务器并查询表[distribution].[dbo].[MSarticles]

从[distribution].[dbo].[MSarticles]中选择*

Simplest way would be to create a linked server to the main server and query the table [distribution].[dbo].[MSarticles].

select * from [distribution].[dbo].[MSarticles]

久光 2024-10-19 18:54:00

看一下 DATABASEPROPERTYEX。它有一个“IsSubscribed”选项,应该可以执行您希望它执行的操作。

Take a look at DATABASEPROPERTYEX. It has an 'IsSubscribed' option that should do what you want it to do.

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