Skip to content
Permalink
Browse files

Get commands count by article for the selected subscriber

  • Loading branch information...
gboge committed Jun 3, 2019
1 parent 85d1706 commit 055e777cad6fd9105ed0af0cec3f8cf166afd8a9
Showing with 4 additions and 3 deletions.
  1. +4 −3 KDatabase.cs
@@ -118,12 +118,12 @@ public static DataTable GetReplicationTransactionsByDatabase(this smo.Database d
/// </summary>
/// <param name="d">Your smo database (distribution)</param>
/// <returns>a datatable</returns>
public static DataTable GetReplicationCommandsByArticle(this smo.Database d)
public static DataTable GetReplicationCommandsByArticle(this smo.Database d, string subscriber)
{
DataTable dt = new DataTable();
if (d.IsDistributor())
{
string sql = @"SELECT s.name AS [Subscriber]
string sql = string.Format(@"SELECT s.name AS [Subscriber]
, sub.publisher_db AS [Database]
, a.article AS [Article]
, COUNT(*) AS [Commands Count]
@@ -134,11 +134,12 @@ public static DataTable GetReplicationCommandsByArticle(this smo.Database d)
AND sub.publication_id = a.publication_id
AND sub.article_id = a.article_id
INNER JOIN sys.servers s ON sub.subscriber_id = s.server_id
WHERE s.name = '{0}'
GROUP BY s.name
, sub.publisher_db
, a.article
ORDER BY [Commands Count] DESC
, [Subscriber]";
, [Subscriber]", subscriber);
dt = d.ExecuteWithResults(sql).Tables[0];
}
return dt;

0 comments on commit 055e777

Please sign in to comment.
You can’t perform that action at this time.