Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmove_gen_rows

  No additional text.


Syntax
create procedure sys.sp_MSmove_gen_rows
    @art_nick int,
    @num_rows_to_move int,
    @gen bigint,
    @changes_in_gen int,
    @target_gen bigint,
    @changes_in_target_gen int,
    @move_contents_rows_too bit = 1
as
    declare @tombstone_rows_moved int
    declare @contents_rows_moved int
    declare @procfailed bit
    declare @error int
    declare @cmd nvarchar(4000)

    select @procfailed = 1

    update top (@num_rows_to_move) dbo.MSmerge_tombstone with (rowlock)
        set generation = @target_gen
        where generation = @gen and tablenick = @art_nick
    select @error = @@error, @tombstone_rows_moved = @@rowcount
    if @error<>0
    begin
        select @procfailed = 1
        goto EXIT_PROC
    end

    if @tombstone_rows_moved > 0
    begin
        update ppm set generation = @target_gen
        from dbo.MSmerge_past_partition_mappings ppm inner join dbo.MSmerge_tombstone ts
        on ppm.tablenick = ts.tablenick
        and ppm.rowguid = ts.rowguid
        and ts.generation = @target_gen
        and ppm.generation = @gen
        and ppm.tablenick = @art_nick
        and ts.tablenick = @art_nick
        if @@error<>0
        begin
            select @procfailed = 1
            goto EXIT_PROC
        end

        select @changes_in_gen = @changes_in_gen - @tombstone_rows_moved
        select @changes_in_target_gen = @changes_in_target_gen + @tombstone_rows_moved

        -- TODO: update the before image object
    end

    -- move contents rows
    if @tombstone_rows_moved < @num_rows_to_move and @move_contents_rows_too = 1
    begin
        select @num_rows_to_move = @num_rows_to_move - @tombstone_rows_moved
        update top (@num_rows_to_move) dbo.MSmerge_contents set generation = @target_gen
        where generation = @gen and tablenick = @art_nick
        select @error = @@error, @contents_rows_moved = @@rowcount
        if @error<>0
        begin
            select @procfailed = 1
            goto EXIT_PROC
        end
        select @changes_in_gen = @changes_in_gen - @contents_rows_moved
        select @changes_in_target_gen = @changes_in_target_gen + @contents_rows_moved
    end

    update dbo.MSmerge_genhistory with (rowlock)
        set changecount = @changes_in_gen where generation = @gen
    if @@error<>0
    begin
        select @procfailed = 1
        goto EXIT_PROC
    end

    update dbo.MSmerge_genhistory with (rowlock)
        set changecount = @changes_in_target_gen where generation = @target_gen
    if @@error<>0
    begin
        select @procfailed = 1
        goto EXIT_PROC
    end


    select @procfailed = 0

EXIT_PROC:
    if (@procfailed = 1)
        return (1)
    else
        return (0)

 
Last revision 2008RTM
See also

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