Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSregistermergesnappubid

  No additional text.


Syntax

-- Name: sp_MSregistermergesnappubid

-- Description: This procedure is used by the merge agent to register the
--              pubid of the publication for which the current snapshot is
--              being delivered in the snapshot delivery progress table. By
--              registering the pubid and the snapshot session token in the
--              snapshot delivery progress table, the merge agent will be
--              able to detect the case where a different snapshot is
--              being delivered over a previously interrupted snapshot.
--              If a different snapshot is being delivered over an
--              interrupted snapshot, this procedure will perform the
--              necessary cleanup in the merge meta-data tables to ensure that
--              the new snapshot can be delivered successfully.

-- Parameters: @snapshot_session_token nvarchar(260) (mandatory)
--             @pubid uniqueidentifier (mandatory)

-- Note: This procedure should only be called by the merge agent at the
--       subscriber database.

-- Returns: 0 - succeeded
--          1 - failed

-- Security: This is a public interface object, security check is performed
--           inside this procedure to restrict access to sysadmins and
--           db_owners of the subscriber database.

create procedure sys.sp_MSregistermergesnappubid (
    @snapshot_session_token nvarchar(260),
    @pubid uniqueidentifier
    )
as
begin
    set nocount on
    declare @retcode int
    declare @pubidprefix nvarchar(100)
    declare @transaction_opened bit
    declare @snapshot_progress_token nvarchar(500)
    declare @snapshot_progress_token_hash nvarchar(500)
    declare @previous_snapshot_session_token nvarchar(260)

    select @retcode = 0
    select @pubidprefix = N':'
    select @transaction_opened = 0
    select @snapshot_progress_token = @pubidprefix + convert(nvarchar(100), @pubid)
    select @snapshot_progress_token_hash = sys.fn_repl32bitstringhash(@snapshot_progress_token)
    select @previous_snapshot_session_token = null

    -- Security check
    exec @retcode = sys.sp_MSreplcheck_subscribe
    if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end

    begin transaction
    save transaction sp_MSregistermergesnappubid
    if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
    select @transaction_opened = 1

    -- Try to pick up the session token of a previously interrupted snapshot
    -- delivery session for this publication
    if object_id('dbo.MSsnapshotdeliveryprogress', 'U') is not null
    begin

        select @previous_snapshot_session_token = session_token
          from dbo.MSsnapshotdeliveryprogress
         where progress_token_hash = @snapshot_progress_token_hash
           and progress_token = @snapshot_progress_token
        if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end

        -- The current snapshot is different from the one interrupted before,
        -- need to do cleanup of the interrupted snapshot
        if @previous_snapshot_session_token is not null and
           @previous_snapshot_session_token <> @snapshot_session_token
        begin
            exec @retcode = sys.sp_MSpurgepartialmergesnapshot
                    @pubid = @pubid
            if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
            exec @retcode = sys.sp_MSrecordsnapshotdeliveryprogress
                    @snapshot_session_token = @snapshot_session_token,
                    @snapshot_progress_token = @snapshot_progress_token
            if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
        end
        else if @previous_snapshot_session_token is null
        begin
            exec @retcode = sys.sp_MSrecordsnapshotdeliveryprogress
                    @snapshot_session_token = @snapshot_session_token,
                    @snapshot_progress_token = @snapshot_progress_token
            if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
        end
    end
    else
    begin
        exec @retcode = sys.sp_MSrecordsnapshotdeliveryprogress
                @snapshot_session_token = @snapshot_session_token,
                @snapshot_progress_token = @snapshot_progress_token
        if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
    end

    commit transaction
    if @@error<>0 or @retcode<>0 begin select @retcode=1 goto Failure end
    select @transaction_opened = 0

Failure:
    if @transaction_opened = 1
    begin
        rollback transaction sp_MSregistermergesnappubid
        commit transaction
    end
    return @retcode
end

 
Last revision 2008RTM
See also

  sp_MSregisterdynsnapseqno (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