Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSupdate_singlelogicalrecordmetadata

  No additional text.


Syntax

-- Requires Certificate signature for catalog access
create procedure sys.sp_MSupdate_singlelogicalrecordmetadata    @logical_record_parent_nickname int,
                                                                @logical_record_parent_rowguid uniqueidentifier,
                                                                @replnick binary(6),
                                                                @parent_row_inserted bit output
as
    declare @logical_record_parent_oldmaxversion int,
            @logical_record_lineage varbinary(311),
            @logical_record_parent_regular_lineage varbinary(311),
            @logical_record_parent_gencur bigint,
            @rows_updated int,
            @error int,
            @logical_record_parent_pubid uniqueidentifier,
            @logical_record_parent_objid int

    select top 1 @logical_record_parent_pubid = pubid, @logical_record_parent_objid = objid
    from dbo.sysmergearticles
    where nickname = @logical_record_parent_nickname
    if (isnull(permissions(@logical_record_parent_objid), 0) & 0x1b = 0 and {fn ISPALUSER(@logical_record_parent_pubid)} <> 1)
    begin
        raiserror(15247, 11, -1)
        return 1
    end

    select @parent_row_inserted = 0

    if @logical_record_parent_rowguid is null
        return 0

    select top 1    @logical_record_parent_oldmaxversion = maxversion_at_cleanup
    from dbo.sysmergearticles
    where nickname = @logical_record_parent_nickname

    exec sys.sp_MSmerge_getgencur @logical_record_parent_nickname, 1, @logical_record_parent_gencur output

    update dbo.MSmerge_tombstone
        set logical_record_lineage = { fn UPDATELINEAGE(logical_record_lineage, @replnick, @logical_record_parent_oldmaxversion+1) }
        where tablenick = @logical_record_parent_nickname
        and rowguid = @logical_record_parent_rowguid
    select @rows_updated = @@rowcount, @error = @@error

    if @error <> 0
        return 1

    if @rows_updated = 1
        return 0 -- no need to insert tombstone if rows_updated = 0. This proc is never called to insert a parent's tombstone.

    update dbo.MSmerge_contents
        set logical_record_lineage = { fn UPDATELINEAGE(logical_record_lineage, @replnick, @logical_record_parent_oldmaxversion+1) }
        where tablenick = @logical_record_parent_nickname
        and rowguid = @logical_record_parent_rowguid
    select @rows_updated = @@rowcount, @error = @@error

    if @error <> 0
        return 1

    if @rows_updated = 0
    begin
        select @logical_record_lineage = { fn UPDATELINEAGE(0x0, @replnick, @logical_record_parent_oldmaxversion+1) }

        -- if no cleanup done yet, use 1 as the version.
        if @logical_record_parent_oldmaxversion = 1
            select @logical_record_parent_regular_lineage = { fn UPDATELINEAGE(0x0, @replnick, 1) }
        else
            select @logical_record_parent_regular_lineage = @logical_record_lineage

        insert into dbo.MSmerge_contents (tablenick, rowguid, lineage, colv1, generation, partchangegen,
                logical_record_parent_rowguid, logical_record_lineage)
            values (@logical_record_parent_nickname, @logical_record_parent_rowguid, @logical_record_parent_regular_lineage,
                0x00, @logical_record_parent_gencur, NULL, @logical_record_parent_rowguid, @logical_record_lineage)
        if @@error <> 0
            return 1

        select @parent_row_inserted = 1
    end

    return 0


 
Last revision 2008RTM
See also

  sp_MSaddmergetriggers_internal (Procedure)
sp_MSaddupdatetrigger (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSdummyupdate90 (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