Is it possible to track transactional replication using Transact SQL

I am trying to monitor continuous replication state using transact sql from a C # application. From my C # application, I successfully run the task using this.

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

Now, I want to know if my synchronization is complete or not or some error has occurred. When the process is complete, I want to give a successful message to the user.

Any help?

+6
source share
1 answer

Yes, we can programmatically track replication using T-SQL or using replication management objects (RMO). For an example, see Programmatically Monitor Replication .

I prefer to use RMO for this, starting the agent and handling the status event and displaying the status of the agent on the 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 can be done for the distribution agent.

+3
source

All Articles