Uredi

Deli z drugimi prek


sp_replmonitorsubscriptionpendingcmds (Transact-SQL)

Applies to: SQL Server Azure SQL Managed Instance

Returns information on the number of pending commands for a subscription to a transactional publication and a rough estimate of how much time it takes to process them. This stored procedure returns one row for each returned subscription. This stored procedure, which is used to monitor replication, is executed at the Distributor on the distribution database.

Transact-SQL syntax conventions

Syntax

sp_replmonitorsubscriptionpendingcmds [ @publisher = ] 'publisher'
    , [ @publisher_db = ] 'publisher_db'
    , [ @publication = ] 'publication'
    , [ @subscriber = ] 'subscriber'
    , [ @subscriber_db = ] 'subscriber_db'
    , [ @subscription_type = ] subscription_type
    , [ @subdb_version = ] subdb_version

Arguments

[ @publisher = ] 'publisher'

The name of the Publisher. publisher is sysname, with no default.

[ @publisher_db = ] 'publisher_db'

The name of the published database. publisher_db is sysname, with no default.

[ @publication = ] 'publication'

The name of the publication. publication is sysname, with no default.

[ @subscriber = ] 'subscriber'

The name of the Subscriber. subscriber is sysname, with no default.

[ @subscriber_db = ] 'subscriber_db'

The name of the subscription database. subscriber_db is sysname, with no default.

[ @subscription_type = ] subscription_type

The type of subscription. subscription_type is int, with no default and can be one of these values.

Value Description
0 Push subscription
1 Pull subscription

[ @subdb_version = ] subdb_version

The dbversion of the subscription database. subdb_version is an optional parameter of type int, with a default value of 0.

Result set

Column name Data type Description
pendingcmdcount int The number of commands that are pending for the subscription.
estimatedprocesstime int Estimate of the number of seconds required to deliver all of the pending commands to the subscriber.

Return code values

0 (success) or 1 (failure).

Remarks

sp_replmonitorsubscriptionpendingcmds is used with transactional replication.

Prior to SQL Server 2019 (15.x) CU17, sp_replmonitorsubscriptionpendingcmds wasn't supported with peer-to-peer replication, and returned an incorrect number of pending commands when used to query peer-to-peer replication topology. In SQL Server 2019 (15.x) CU 17, support was added to make sp_replmonitorsubscriptionpendingcmds compatible with peer-to-peer publications.

However, even with SQL Server 2019 (15.x) CU17 or later, sp_replmonitorsubscriptionpendingcmds could report an incorrect number of pending commands when used with peer-to-peer replication if the table MSrepl_originators contains a stale entry of an incorrect version of the subscription database. To correct the problem, either delete all the stale entries from MSrepl_originators or pass the correct dbversion of the subscription database when using the subdb_version argument for the sp_replmonitorsubscriptionpendingcmds stored procedure.

See KB5017009 for details on how to determine dbversion.

Permissions

Only members of the sysadmin fixed server role at the Distributor or members of the db_owner fixed database role in the distribution database can execute sp_replmonitorsubscriptionpendingcmds. Members of the publication access list for a publication that uses the distribution database can execute sp_replmonitorsubscriptionpendingcmds to return pending commands for that publication.