Skip to content

Commit

Permalink
Get commands count by article for the selected subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
gboge committed Jun 3, 2019
1 parent 85d1706 commit 055e777
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions KDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ GROUP BY d.publisher_db
/// </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]
Expand All @@ -134,11 +134,12 @@ INNER JOIN dbo.MSarticles a (NOLOCK) ON sub.publisher_id = a.publisher_id
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;
Expand Down

0 comments on commit 055e777

Please sign in to comment.