Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdelete_specifiedcontentsandtombstone

  No additional text.


Syntax
create procedure sys.sp_MSdelete_specifiedcontentsandtombstone
    @num_contents_rows int = 0 output,
    @num_tombstone_rows int = 0 output
as
    declare @retcode smallint
    declare @delbatchsize int

    set @delbatchsize= 5000

    -- iterate over articles in the temptable
    declare @artnick int
    declare article_curs cursor local fast_forward for
        select distinct artnick from #oldgens

    open article_curs
    fetch next from article_curs into @artnick

    while (@@fetch_status <> -1)
    begin
        -- if necessary, update highest version in dbo.sysmergearticles
        exec @retcode= sp_MSsethighestversion @artnick= @artnick
        if @retcode<>0 or @@error<>0 goto Failure

        -- clean up orphaned rows in MSmerge_contents
        declare @delcount int

        set @delcount= @delbatchsize
        while @delcount = @delbatchsize
        begin
            delete top (@delbatchsize) cpm from dbo.MSmerge_current_partition_mappings as cpm with (rowlock)
            where cpm.tablenick = @artnick
            and exists
                (select mc.tablenick, mc.rowguid from dbo.MSmerge_contents as mc inner join #oldgens as og
                    on (mc.tablenick = og.artnick and mc.generation = og.gen)
                    where mc.tablenick = @artnick
                    and mc.tablenick = cpm.tablenick
                    and mc.rowguid = cpm.rowguid)
            set @delcount= @@rowcount
        end

        set @delcount= @delbatchsize
        while @delcount = @delbatchsize
        begin
            delete top (@delbatchsize) ppm from dbo.MSmerge_past_partition_mappings as ppm
            inner join #oldgens as og on (ppm.tablenick = og.artnick and ppm.generation = og.gen) where ppm.tablenick = @artnick

            set @delcount= @@rowcount
        end

        set @delcount= @delbatchsize
        while @delcount = @delbatchsize
        begin
            delete top (@delbatchsize) mc from dbo.MSmerge_contents as mc inner join #oldgens as og
                on (mc.tablenick = og.artnick and mc.generation = og.gen)
                where mc.tablenick = @artnick
            set @delcount= @@rowcount
            set @num_contents_rows = @num_contents_rows + @delcount
        end

        set @delcount= @delbatchsize
        while @delcount = @delbatchsize
        begin
            delete top (@delbatchsize) mt from dbo.MSmerge_tombstone as mt inner join #oldgens as og
                on (mt.tablenick = og.artnick and mt.generation = og.gen)
                where mt.tablenick = @artnick
            set @delcount= @@rowcount
            set @num_tombstone_rows = @num_tombstone_rows + @delcount
        end

        -- get next article
        fetch next from article_curs into @artnick
    end

    close article_curs
    deallocate article_curs
    return(0)

Failure:
    close article_curs
    deallocate article_curs
    return (1)

 
Last revision 2008RTM
See also

  sp_MScleanup_zeroartnick_genhistory (Procedure)
sp_MSdrop_rlcore (Procedure)
sp_MSpurgecontentsorphans (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