PublisherMonitor.EnumMergeAgentSessions2 Method

Returns additional information about Merge Agent sessions.

Namespace:  Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Rmo (in Microsoft.SqlServer.Rmo.dll)

Syntax

'Declaration
Public Function EnumMergeAgentSessions2 ( _
    agentName As String, _
    sessionDuration As Integer, _
    returnOnlyErrorSessions As Boolean _
) As DataSet
'Usage
Dim instance As PublisherMonitor 
Dim agentName As String 
Dim sessionDuration As Integer 
Dim returnOnlyErrorSessions As Boolean 
Dim returnValue As DataSet 

returnValue = instance.EnumMergeAgentSessions2(agentName, _
    sessionDuration, returnOnlyErrorSessions)
public DataSet EnumMergeAgentSessions2(
    string agentName,
    int sessionDuration,
    bool returnOnlyErrorSessions
)
public:
DataSet^ EnumMergeAgentSessions2(
    String^ agentName, 
    int sessionDuration, 
    bool returnOnlyErrorSessions
)
member EnumMergeAgentSessions2 : 
        agentName:string * 
        sessionDuration:int * 
        returnOnlyErrorSessions:bool -> DataSet
public function EnumMergeAgentSessions2(
    agentName : String, 
    sessionDuration : int, 
    returnOnlyErrorSessions : boolean
) : DataSet

Parameters

  • sessionDuration
    Type: System.Int32
    An Int32 value that specifies the number of hours before the current time to which to limit the results. For example, a value of 24 will return information about agent sessions over the last 24 hours. A value of -1 returns information on the last 100 sessions, and a value of 0 returns information on all sessions.
  • returnOnlyErrorSessions
    Type: System.Boolean
    A Boolean value that specifies whether to returns information only on sessions that resulted in an error or on all sessions. If true, only error sessions are returned. If false, all sessions are returned.

Return Value

Type: System.Data.DataSet
A DataSet object that contains the following columns.

Column

Data type

Description

Session_id

Int32

ID of the agent job session.

Status

Int32

Agent run status:

1 = Start

2 = Succeed

3 = In progress

4 = Idle

5 = Retry

6 = Fail

StartTime

DateTime

Time the agent job session began.

EndTime

DateTime

Time the agent job session was completed.

Duration

Int32

Cumulative duration, in seconds, of the agent job session.

UploadedCommands

Int32

Number of commands uploaded during the agent job session.

DownloadedCommands

Int32

Number of commands downloaded during the agent job session.

ErrorMessages

Int32

Number of error messages that were generated during the agent job session.

ErrorID

Int32

ID of the error that occurred

PercentageDone

Decimal

Estimated percentage of the total changes that have already been delivered in an active session.

TimeRemaining

Int32

Estimated number of seconds left in an active session.

CurrentPhase

Int32

Is the current phase of an active session, which can be one of the following:

1 = Upload

2 = Download

LastMessage

String

Is the last message logged by Merge Agent during the session.

Remarks

You should commit any property changes to the PublisherMonitor object before calling this method because properties of this object may need to be loaded if they have not been loaded already.

The EnumMergeAgentSessions2 method can only be called by members of the db_owner or replmonitor fixed database roles on the distribution database.

Calling EnumMergeAgentSessions2 is equivalent to executing sp_replmonitorhelpmergesession (Transact-SQL).

See Also

Reference

PublisherMonitor Class

Microsoft.SqlServer.Replication Namespace

EnumMergeAgentSessionDetails2

EnumMergeAgentSessions

Other Resources

NIB Programmatically Monitor Replication (RMO Programming)