Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can I check if there are commands waiting for being executed in the subscribers and find if there is any error occurring in my publication.

I want to be able to do this programmatically so the replication monitors is not an option.

The objective is to give some feedback to a C# program, so that the program can adapt his behaviour, depending on the possible problems.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

This can be done by monitoring replication via Replication Management Objects (RMO).

RMO allows programmatic control of Replication via the Microsoft.SqlServer.Replication namespace and can be used to monitor a Replication topology.

Here are some links to get you started:

Replication Management Object Concepts

How to: Programmatically Monitor Replication (RMO Programming)

share|improve this answer
add comment

The application to do this with is the replication monitor. To use it log into SQL Server Management Studio and connect to the publisher. Right click on Replication in the tree and select Launch Replication Monitor (it might not be labeled exactly that). Connect that to the distributor and you can see the replication status.

This app uses a funky set of custom queries as well as some stored procedures to figure out what's going on. If you needed to see what's going on you'll want to run SQL profiler against the distributor so you can see how the data is flowing. That way you can see all the commands that the replication monitor is using.

share|improve this answer
    
but is there a way to do this programatically? a query to select the commands waiting in the distribuitor for example... Because a C# aplication can't "talk" with the replication monitor –  RagnaRock Nov 29 '11 at 16:58
    
Yes, launch the replication monitor and run SQL Profiler to see what the commands are that are being run against the distribution database. You can then build those queries into your application. I wouldn't really worry about montioring the distribution database as replication being slow won't effect the performance of your system, and the replication will eventually catch up. –  mrdenny Nov 29 '11 at 17:00
    
any tips in how to use the profiler, i'm using it for the first time, what kind of event should I look for, I'm overwhelmed with unusefull code/events (I was unaware of so many things running in background, while apparently the database is doing nothing) –  RagnaRock Nov 29 '11 at 17:28
    
It's been a long time since I've looked at the commands that replication monitor runs. Basically you'll need to capture about a minutes worth of information then start looking for select statements and run them to see what data comes back until you find the queries you are looking for. –  mrdenny Nov 29 '11 at 17:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.