Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSevaluate_logicalrecordparent

  No additional text.


Syntax

-- Requires Certificate signature for catalog access
create procedure sys.sp_MSevaluate_logicalrecordparent @nickname int, @rowguid uniqueidentifier
as
    declare @objid int
            , @logical_record_view_name nvarchar(270)
            , @rgcol nvarchar(270)
            , @replnick binary(6)
            , @retcode int
            , @in_tran bit
            , @command nvarchar(max)
            , @logical_record_parent_oldmaxversion int
            , @logical_record_parent_nickname int
            , @logical_record_parent_rowguid uniqueidentifier
            , @logical_record_parent_gencur bigint
            , @logical_record_parent_regular_lineage varbinary(311)
            , @logical_record_lineage varbinary(311)

    -- If this article is not in a logical record relationship, return without doing anything
    select @objid = objid, @logical_record_view_name = 'dbo.' + quotename(object_name(logical_record_view)),
            @logical_record_parent_nickname = logical_record_parent_nickname
    from dbo.sysmergepartitioninfoview
    where nickname = @nickname
    and logical_record_view is not null

    if @logical_record_view_name is null
        return 0

    set @retcode = 1

    select @rgcol = quotename(name) from sys.columns
    where object_id = @objid
    and is_rowguidcol = 1

    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

    exec @retcode = sys.sp_MSgetreplnick @replnick = @replnick output
    if @@error <> 0 or @retcode <> 0
        goto EXIT_PROC

    select @command = N'
    select @logical_record_parent_rowguid = logical_record_parent_rowguid
    from ' + @logical_record_view_name + '
    where ' + @rgcol + ' = @rowguid '

    begin tran
    save tran eval_logical_record_parent
    select @in_tran = 1

    exec sys.sp_executesql @command,
        N'@logical_record_parent_rowguid uniqueidentifier output,
        @rowguid uniqueidentifier',
        @logical_record_parent_rowguid = @logical_record_parent_rowguid output,
        @rowguid = @rowguid
    if @@error <> 0
        goto EXIT_PROC

    update dbo.MSmerge_contents
    set logical_record_parent_rowguid = @logical_record_parent_rowguid
    where tablenick = @nickname
    and rowguid = @rowguid

    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

    if @@rowcount = 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)

        exec @retcode = sys.sp_MSevaluate_change_membership_for_row @tablenick = @logical_record_parent_nickname,
            @rowguid = @logical_record_parent_rowguid
        if @@error <> 0 or @retcode <> 0
        goto EXIT_PROC

    end

    commit tran
    select @in_tran = 0

    select @retcode = 0

EXIT_PROC:

if @in_tran = 1
begin
    rollback tran eval_logical_record_parent
    commit tran
    select @in_tran = 0
end

return @retcode

 
Last revision 2008RTM
See also

  sp_addtabletocontents (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSdummyupdate (Procedure)
sp_MSdummyupdate90 (Procedure)
sp_MSevaluate_logicalrecordparent_allcontentsrows (Procedure)
sp_MSsetrowmetadata (Procedure)
sp_MSsetup_partition_groups (Procedure)
sp_MSsetup_publication_for_partition_groups (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