sp_replmonitorhelpmergesession (Transact-SQL)

 

Applies To: SQL Server

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.

Topic link icon Transact-SQL Syntax Conventions

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

[ @agent_name = ] 'agent_name'
Is the name of the agent. agent_name is nvarchar(100) with no default.

[ @hours = ] hours
Is the range of time, in hours, for which historical agent session information is returned. hours is int, which can be one of the following ranges.

ValueDescription
< 0Returns information on past agent runs, up to a maximum of 100 runs.
0 (default)Returns information on all past agent runs.
> 0Returns 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.

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

[ @publisher = ] 'publisher'
Is 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 = ] 'publisher_db'
Is 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= ] 'publication'
Is the name of the publication. publication is sysname, with a default of NULL. This parameter is used when executing sp_replmonitorhelpmergesession at the Subscriber.

Column nameData typeDescription
Session_idintID of the agent job session.
StatusintAgent run status:

 1 = Start

 2 = Succeed

 3 = In progress

 4 = Idle

 5 = Retry

 6 = Fail
StartTimedatetimeTime agent job session began.
EndTimedatetimeTime agent job session was completed.
DurationintCumulative duration, in seconds, of this job session.
UploadedCommandsintNumber of commands uploaded during the agent session.
DownloadedCommandsintNumber of commands downloaded during the agent session.
ErrorMessagesintNumber of error messages that were generated during the agent session.
ErrorIDintID of the error that occurred
PercentageDonedecimalEstimated percent of the total changes that have already been delivered in an active session.
TimeRemainingintEstimated number of seconds left in an active session.
CurrentPhaseintIs the current phase of an active session, which can be one of the following.

 1 = Upload

 2 = Download
LastMessagenvarchar(500)Is the last message logged by Merge Agent during the session.

0 (success) or 1 (failure)

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.

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.

Programmatically Monitor Replication

Community Additions

ADD
Show: