Επεξεργασία

Κοινή χρήση μέσω


sp_replmonitorhelpmergesession (Transact-SQL)

Applies to: SQL Server Azure SQL Managed Instance

Returns information on past sessions for a given replication Merge Agent, with one row returned for each session that matches the filtering criterion. This stored procedure, which is used to monitor merge replication, is executed at the Distributor on the distribution database or at the Subscriber on the subscription database.

Transact-SQL syntax conventions

Syntax

sp_replmonitorhelpmergesession
    [ [ @agent_name = ] N'agent_name' ]
    [ , [ @hours = ] hours ]
    [ , [ @session_type = ] session_type ]
    [ , [ @publisher = ] N'publisher' ]
    [ , [ @publisher_db = ] N'publisher_db' ]
    [ , [ @publication = ] N'publication' ]
[ ; ]

Arguments

[ @agent_name = ] N'agent_name'

The name of the agent. @agent_name is nvarchar(100), with no default.

[ @hours = ] hours

The range of time, in hours, for which historical agent session information is returned. @hours is int, and can be one of the following ranges.

Value Description
< 0 Returns information on past agent runs, up to a maximum of 100 runs.
0 (default) Returns information on all past agent runs.
> 0 Returns information on agent runs that occurred in the last hours number of hours.

[ @session_type = ] session_type

Filters the result set based on the session end result. @session_type is int, and can be one of these values.

Value Description
1 (default) Agent sessions with a retry or succeed result.
0 Agent sessions with a failure result.

[ @publisher = ] N'publisher'

The name of the Publisher. @publisher is sysname, with a default of NULL. This parameter is used when executing sp_replmonitorhelpmergesession at the Subscriber.

[ @publisher_db = ] N'publisher_db'

The name of the publication database. @publisher_db is sysname, with a default of NULL. This parameter is used when executing sp_replmonitorhelpmergesession at the Subscriber.

[ @publication = ] N'publication'

The name of the publication. @publication is sysname, with a default of NULL. This parameter is used when executing sp_replmonitorhelpmergesession at the Subscriber.

Result set

Column name Data type Description
Session_id int ID of the agent job session.
Status int Agent run status:

1 = Start

2 = Succeed

3 = In progress

4 = Idle

5 = Retry

6 = Fail
StartTime datetime Time agent job session began.
EndTime datetime Time agent job session was completed.
Duration int Cumulative duration, in seconds, of this job session.
UploadedCommands int Number of commands uploaded during the agent session.
DownloadedCommands int Number of commands downloaded during the agent session.
ErrorMessages int Number of error messages that were generated during the agent session.
ErrorID int ID of the error that occurred
PercentageDone decimal Estimated percent of the total changes that have already been delivered in an active session.
TimeRemaining int Estimated number of seconds left in an active session.
CurrentPhase int The current phase of an active session, and can be one of the following.

1 = Upload

2 = Download
LastMessage nvarchar(500) The last message logged by Merge Agent during the session.

Return code values

0 (success) or 1 (failure).

Remarks

sp_replmonitorhelpmergesession is used to monitor merge replication.

When executed on the Subscriber, sp_replmonitorhelpmergesession only returns information on the last five Merge Agent sessions.

Permissions

Only members of the db_owner or replmonitor fixed database role on the distribution database at the Distributor or on the subscription database at the Subscriber can execute sp_replmonitorhelpmergesession.