Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to monitor transactional replication using Transact SQL

I am trying to monitor continuous replication status using transact sql from c# application. From my c# application i successfully start the job by using this..

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?

like image 896
Hasib Tarafder Avatar asked Nov 11 '12 09:11

Hasib Tarafder


1 Answers

Yes, we can programmatically monitor replication using T-SQL or by using Replication Management Objects (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. 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/

The same thing could be done for the Distribution Agent.

like image 94
Brandon Williams Avatar answered Oct 15 '22 08:10

Brandon Williams