简体   繁体   English

是否可以使用Transact SQL监视事务复制

[英]Is it possible to monitor transactional replication using Transact SQL

I am trying to monitor continuous replication status using transact sql from c# application. 我正在尝试使用c#application中的transact sql监视连续复制状态。 From my c# application i successfully start the job by using this.. 从我的c#应用程序我成功启动这项工作..

exec sp_startpushsubscription_agent
   @publication = 'myPublication',
   @subscriber = 'my_subscriber_server_name',
   @subscriber_db = 'my_subscriber_db'

Now, I want to know whether my synchronization is complete or not or any error occurred. 现在,我想知道我的同步是否完成或是否发生了任何错误。 When the process is finished i want to give a successful message to the user. 当过程完成时,我想向用户发出成功的消息。

Any help? 有帮助吗?

Yes, we can programmatically monitor replication using T-SQL or by using Replication Management Objects (RMO). 是的,我们可以使用T-SQL或使用复制管理对象(RMO)以编程方式监视复制。 Please see Programmatically Monitor Replication for examples. 有关示例,请参阅以编程方式监视复制

I prefer to use RMO for this, starting the agent and handling the Status Event and displaying the agent status on a form. 我更喜欢使用RMO,启动代理并处理状态事件并在表单上显示代理状态。 I have an example of how to do this for the Merge Agent on my blog: http://www.sqlrepl.com/sql-server/implementing-a-replication-agent-progess-bar/ 我在博客上有一个如何为合并代理执行此操作的示例: http//www.sqlrepl.com/sql-server/implementing-a-replication-agent-progess-bar/

The same thing could be done for the Distribution Agent. 可以为分发代理程序执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM