Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSenum_merge_s

  No additional text.


Syntax
create procedure sys.sp_MSenum_merge_s
(
@name nvarchar(100),
@hours int = 0, /* @hours < 0 will return TOP 100 */
@session_type int = 1 /* Return all sessions */
)
as
begin
    set nocount on

    declare @succeed int
    declare @agent_id int
    declare @retry int
    declare @failure int
    declare @min_time datetime

    
    -- security check
    -- only replmonitor can execute this
    
    if not (is_member(N'db_owner') = 1 or isnull(is_member(N'replmonitor'),0) = 1)
    begin
        raiserror(14260, 16, -1)
        return (1)
    end
    /*
    ** Status const defined in sqlrepl.h
    */
    select @succeed = 2
    select @retry = 5
    select @failure = 6

    select @agent_id = id from dbo.MSmerge_agents where name = @name

    /* Get date starting point */
    IF @hours < 0
    BEGIN
        select top 100 ms.runstatus,
            'start_time' = sys.fn_replformatdatetime(ms.start_time),
            'time' = sys.fn_replformatdatetime(ms.end_time),
            rh.comments, ms.duration,
            -- Note: return average rate here !!! delivery_rate column is current rate
            ms.delivery_rate,
            ms.download_inserts, ms.download_updates, ms.download_deletes, ms.download_conflicts,
            ms.upload_inserts, ms.upload_updates, ms.upload_deletes, ms.upload_conflicts,
            'action_count' = (select count(*) from dbo.MSmerge_history with (READPAST) where
                session_id = ms.session_id and agent_id = @agent_id),
            rh.error_id
            from dbo.MSmerge_history rh with (READPAST), dbo.MSmerge_sessions ms with (READPAST)
            where
            ms.agent_id = @agent_id and
            ((@session_type = 1 and
            (ms.runstatus = @succeed or
            ms.runstatus = @retry or
            ms.timestamp = (select max(ms2.timestamp) from dbo.MSmerge_sessions ms2 with (READPAST) where
                ms2.agent_id = @agent_id))) or
            ms.runstatus = @failure) and
            ms.session_id = rh.session_id and
            ms.agent_id = rh.agent_id and
            rh.timestamp = (select max(rh2.timestamp) from dbo.MSmerge_history rh2 with (READPAST) where
                rh2.agent_id = @agent_id and rh2.session_id=ms.session_id)
            order by ms.session_id desc
    END
    ELSE
    BEGIN
        IF @hours = 0
        BEGIN
            select @min_time = NULL
        END
        ELSE
        BEGIN
            select @min_time = dateadd(hour, -@hours, getdate())
        END
        select  ms.runstatus,
            'start_time' = sys.fn_replformatdatetime(ms.start_time),
            'time' = sys.fn_replformatdatetime(ms.end_time),
            rh.comments, ms.duration,
            -- Note: return average rate here !!! delivery_rate column is current rate
            ms.delivery_rate,
            ms.download_inserts, ms.download_updates, ms.download_deletes, ms.download_conflicts,
            ms.upload_inserts, ms.upload_updates, ms.upload_deletes, ms.upload_conflicts,
            'action_count' = (select count(*) from dbo.MSmerge_history with (READPAST) where
                session_id = ms.session_id and agent_id = @agent_id),
            rh.error_id
            from dbo.MSmerge_history rh with (READPAST), dbo.MSmerge_sessions ms with (READPAST)
            where
            ms.agent_id = @agent_id and
            ((@session_type = 1 and
            (ms.runstatus = @succeed or
            ms.runstatus = @retry or
            ms.timestamp = (select max(ms2.timestamp) from dbo.MSmerge_sessions ms2 with (READPAST) where
                ms2.agent_id = @agent_id))) or
            ms.runstatus = @failure) and
            (ms.end_time >= @min_time or @min_time IS NULL) and
               ms.session_id = rh.session_id and
            ms.agent_id = rh.agent_id and
            rh.timestamp = (select max(rh2.timestamp) from dbo.MSmerge_history rh2 with (READPAST) where
                rh2.agent_id = @agent_id and rh2.session_id=ms.session_id)
            order by ms.session_id desc
    END
end

 
Last revision 2008RTM
See also

  sp_instdist (Procedure)
sp_MSenum_merge_sd (Procedure)
sp_MSenum_merge_subscriptions (Procedure)
sp_MSenum_merge_subscriptions_90_publication (Procedure)
sp_MSenum_merge_subscriptions_90_publisher (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash