SQL Server:订阅:如何知道表是否处于复制/订阅状态
在SQL Server中,在“订阅端”,如何知道表是否处于复制/订阅状态?
有什么想法吗?
In SQL Server, on the "Subscription side", how can you know if a table is under replication/subscription?
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我不确定对此有一个简单的答案,并且我认为答案可能会根据复制类型而有所不同。我认为你可能必须依靠启发法来回答这个问题。
对于快照复制,我想不出任何会泄露游戏信息的东西。显然,复制表的存在(例如
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 usesys.sql_dependencies
to locate the tables that these relate toFor 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 insysmergesubscriptions
to determine that you're on the subscription side.转至订阅者数据库检查表
dbo.MSreplication_subscriptions
。如果数据库是subscriber
,您将找到此表。另外,要查找文章,请在subscribed
数据库中使用它Go to the subscriber database check for the table
dbo.MSreplication_subscriptions
. If the database issubscriber
, you will find this table. Also, to find out articles use this in thesubscribed
database我使用非信徒达米安的想法(+1)来生成对我有用的代码
I used Damien the Unbeliever's idea (+1) to produce this code that worked for me
最简单的方法是创建一个到主服务器的链接服务器并查询表
[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]
看一下 DATABASEPROPERTYEX。它有一个“IsSubscribed”选项,应该可以执行您希望它执行的操作。
Take a look at DATABASEPROPERTYEX. It has an 'IsSubscribed' option that should do what you want it to do.