SQL Server with Mr. Denny

Jan 14 2015   5:00PM GMT

Monitoring SQL Replication Latency

Denny Cherry Denny Cherry Profile: Denny Cherry

Database replication
SQL Server
SQL Server 2005
SQL Server 2008
SQL Server 2008 R2
SQL Server 2012
SQL Server 2014
SQL Server Distributor

When working with SQL Server replication, you don’t have a whole lot of options for monitoring the latency of the replication. You’ve got the SQL Server Replication Monitor, and that’s basically it.

Well there is another option. You can manually run the code that the replication monitor uses to get those values that it displays.

To run it for a single publication, which is how the replication monitor uses the procedure you’d run it like this.

exec [distribution].sys.sp_replmonitorhelpsubscription @publisher = N’MyPublisher’, @publisher_db = N’MyDatabase’, @publication = ‘MyPublication’, @mode = 0, @exclude_anonymous = 0, @refreshpolicy = N’0′

But that only gives you data for the single publication for the single database. Any (or all) of the @Publisher, @publisher_db and @publication values can be null making them wildcard values. When this is done it’ll give you the information for all the publications, publishers and databases that match the wildcard. Below you can see that I’ll pulling the values for every publication which is monitored by the distributor.

exec [distribution].sys.sp_replmonitorhelpsubscription @publisher = NULL, @publisher_db = NULL, @publication = NULL, @mode = 0, @exclude_anonymous = 0, @refreshpolicy = N’0′, @publication_type=0

Now if I had a monitoring application I could have it run this stored procedure and look for values where the latency column is more than some value, say 120 seconds.


 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: