Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_mergesubscriptionsummary

  No additional text.


Syntax

-- Name:
--  sp_mergesubscriptionsummary

-- Description:
--  Returns the status summary of the merge agent for the specified
--  merge subscription.

-- Returns:
--  0 : success
--  1 : failure

-- Security:
--  Public procedure, internal PAL check.
--  Requires Certificate signature for catalog access

CREATE PROCEDURE sys.sp_mergesubscriptionsummary
(
    @publication    sysname,
    @subscriber     sysname,
    @subscriber_db  sysname
)
AS
BEGIN
    SET NOCOUNT ON
    DECLARE @retcode            int,
            @distributor_rpc    sysname,
            @distributor        sysname,
            @distribution_db    sysname,
            @pubid              uniqueidentifier,
            @procedure          nvarchar(4000),
            @publisher          sysname,
            @publisher_db       sysname

    SET @retcode        = 0
    SET @publisher      = publishingservername()
    SET @publisher_db   = db_name()

    
    -- PAL check and validate publication
    
    exec @retcode = sp_MSreplcheck_pull @publication = @publication,
                                        @raise_fatal_error = 0
    IF (@@error != 0) OR (@retcode != 0)
        RETURN 1

    -- Make sure current database is enabled for merge replication
    EXEC @retcode = sys.sp_MSCheckmergereplication
    IF (@@error != 0) OR (@retcode != 0)
        RETURN 1

    -- Parameter check: @subscriber
    IF @subscriber IS NULL
    BEGIN
        -- "The parameter @subscriber cannot be NULL."
        RAISERROR (14043, 16, -1, '@subscriber', 'sp_mergesubscriptionsummary')
        RETURN 1
    END

    SELECT @pubid = pubid
      FROM dbo.sysmergepublications
     WHERE UPPER(publisher) = UPPER(@publisher)
       AND publisher_db = @publisher_db
       AND name = @publication
    IF @pubid IS NULL
    BEGIN
        -- The publication '@publication' does not exist.
        RAISERROR (20026, 16, -1, @publication)
        RETURN 1
    END

    IF NOT EXISTS (SELECT *
                     FROM dbo.sysmergesubscriptions
                    WHERE UPPER(subscriber_server) = UPPER(@subscriber)
                      AND db_name = @subscriber_db
                      AND pubid = @pubid) -- We allow retrieval of push and (well-known) pull merge agent status
    BEGIN
        -- "The subscription could not be found."
        RAISERROR (20021, 16, -1)
        RETURN 1
    END

    EXEC @retcode = sys.sp_helpdistributor
            @rpcsrvname = @distributor_rpc OUTPUT,
            @distribdb = @distribution_db OUTPUT
    IF (@@error != 0) OR (@retcode != 0) OR @distribution_db IS NULL
    BEGIN
        -- "The Distributor has not been installed correctly."
        RAISERROR (20036, 16, -1)
        RETURN 1
    END

    DECLARE @merge_status           int,
            @merge_message          nvarchar(1000),
            @merge_time             datetime,
            @merge_duration         int,
            @merge_percent_complete decimal(5,2)

    SET @procedure = QUOTENAME(RTRIM(@distributor_rpc)) + '.' + QUOTENAME(RTRIM(@distribution_db)) + '.sys.sp_MSrepl_mergeagentstatussummary'
    EXEC @retcode = @procedure
            @publisher = @publisher,
            @publisher_db = @publisher_db,
            @publication = @publication,
            @subscriber = @subscriber,
            @subscriber_db = @subscriber_db,
            @merge_status = @merge_status OUTPUT,
            @merge_message = @merge_message OUTPUT,
            @merge_time = @merge_time OUTPUT,
            @merge_duration = @merge_duration OUTPUT,
            @merge_percent_complete = @merge_percent_complete OUTPUT

    IF (@@error != 0) OR (@retcode != 0)
    BEGIN
        RETURN 1
    END

    SELECT @merge_status AS merge_status,
           @merge_message AS merge_message,
           @merge_time AS merge_time,
           @merge_duration AS merge_duration,
          @merge_percent_complete AS merge_percent_complete

    RETURN (@retcode)
END

 
Last revision 2008RTM
See also

  sp_MSdrop_replcom (Procedure)
sp_MSrepl_mergeagentstatussummary (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