Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSsetupnotbelongs

  No additional text.


Syntax
create procedure sys.sp_MSsetupnotbelongs
@artnick            int,
@before_view_objid  int,
@before_table_objid int,
@rgcol              sysname,
@commongen          bigint,
@allow_partition_realignment bit
AS
    declare @before_view_name sysname
    declare @before_table_name sysname
    declare @command nvarchar(4000)
    declare @retcode int

    /* Put changes in #notbelong  that aren't in #belong and have a relevant partchangegen  */
    -- If publication has before image tables, we should screen changes using the before image tables
    --rowguid in (select ' + @rgcol + ' from ' + @before_view_name + ') and
    if OBJECT_NAME(@before_view_objid) is not null
    begin
        set @before_view_name = OBJECT_NAME(@before_view_objid)
        set @before_table_name = OBJECT_NAME(@before_table_objid)

        -- Do not convert partition realignment to deletes if the allow_partition_realignment
        -- is set to false.
        if @allow_partition_realignment = 1
        begin
            set @command = 'insert into #notbelong (tablenick, rowguid, flag, partchangegen)
                    select tablenick, rowguid, 0, partchangegen
                    from #contents_subset
                    where partchangegen > @commongen
                    and tablenick = @artnick
                    and rowguid in (select ' + quotename(@rgcol) + ' from ' + quotename(@before_view_name) + ')
                    and rowguid not in (select rowguid from #belong where tablenick = @artnick)
                    union
                    select tablenick, rowguid, 0, partchangegen
                    from #contents_subset
                    where partchangegen > @commongen
                    and tablenick = @artnick
                    and rowguid in (select ' + quotename(@rgcol) + ' from ' + quotename(@before_table_name) + ' where system_delete = 1)
                    and rowguid not in (select rowguid from #belong where tablenick = @artnick)'
			exec @retcode = sp_executesql @command, N'@commongen int, @artnick int', @commongen=@commongen, @artnick=@artnick
			if @@error <> 0 or @retcode <> 0
            begin
                    return (1)
            end

            if exists (select * from #genlist)
            begin
                /* Add tombstones to ##notbelong */
                set @command = 'insert into #notbelong (tablenick, rowguid, flag, partchangegen, type)
                        select tablenick, rowguid,  0, generation, type from
                        #tombstone_subset where tablenick = @artnick and
                        type = 6
                        union
                        select tablenick, rowguid,  0, generation, type from
                        #tombstone_subset where tablenick = @artnick and
                        rowguid in (select ' + quotename(@rgcol) + ' from ' + quotename(@before_view_name) + ')'
				exec @retcode = sp_executesql @command, N'@artnick int', @artnick=@artnick
				if @@error <> 0 or @retcode <> 0
                begin
                        return (1)
                end
            end
        end
        else
        begin
            if exists (select * from #genlist)
            begin
                /* Add tombstones to ##notbelong */
                set @command = 'insert into #notbelong (tablenick, rowguid, flag, partchangegen, type)
                        select tablenick, rowguid,  0, generation, type from
                        #tombstone_subset where tablenick = @artnick and type = 6
                        union
                        select tablenick, rowguid,  0, generation, type from
                        #tombstone_subset where tablenick = @artnick and
                        rowguid in (select ' + quotename(@rgcol) + ' from ' + quotename(@before_view_name) + ' where generation > @commongen)'
				exec @retcode = sp_executesql @command, N'@commongen int, @artnick int', @commongen=@commongen, @artnick=@artnick
				if @@error <> 0 or @retcode <> 0
                begin
                        return (1)
                end
            end
        end
    end
    else
    begin
        -- Do not convert partition realignment to deletes if the allow_partition_realignment
        -- is set to false.
        if @allow_partition_realignment = 1
        begin
            insert into #notbelong (tablenick, rowguid, flag, partchangegen)
                    select tablenick, rowguid, 0, partchangegen
                    from #contents_subset
                    where partchangegen > @commongen
                    and tablenick = @artnick
                    and rowguid not in (select rowguid from #belong where tablenick = @artnick)

            if @@ERROR <>0
            begin
                return (1)
            end
        end

        if exists (select * from #genlist)
        begin
            insert into #notbelong (tablenick, rowguid, flag, partchangegen, type)
                  select tablenick, rowguid,  0, generation, type from
            #tombstone_subset where tablenick = @artnick

            if @@ERROR <>0
            begin
                    return (1)
            end
        end
    end

    return (0)

 
Last revision 2008RTM
See also

  sp_MSdrop_rlrecon (Procedure)
sp_MSsetupbelongs (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