Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmark_expired_subscriptions

  No additional text.


Syntax
create procedure sys.sp_MSmark_expired_subscriptions as
begin
    declare @min_sentgen bigint
    declare @max_delgen bigint

    select top 1 @min_sentgen = isnull(sentgen,0) from dbo.sysmergesubscriptions
    where status = 1
    and cleanedup_unsent_changes = 0
    order by sentgen

    if @min_sentgen is null
        return 0

    if exists (select * from #oldgens where gen > @min_sentgen)
    begin

        select top 1 @max_delgen = gen from #oldgens
        order by gen desc

        -- If this is not a leaf level subscriber, or alt sync partners are being used, make all the generations being cleaned up
        -- look like local generations in the temp table #oldgens
		if exists (select * from dbo.sysmergepublications where publisher_db = db_name() and UPPER(publisher) = UPPER (publishingservername()))
		or exists (select * from dbo.sysmergepublications where allow_synctoalternate = 1)
		begin
			update #oldgens set genstatus = 1
		end

        update dbo.sysmergesubscriptions set cleanedup_unsent_changes = 1
            -- , status = case when replica_version < 90 then 2 else status end
        from dbo.sysmergesubscriptions sms1 join
        (
            select sms.subid
            from #oldgens og join dbo.MSmerge_generation_partition_mappings gpm
            on og.gen = gpm.generation
            and og.gen > @min_sentgen
            and og.genstatus <> 2
            join dbo.sysmergesubscriptions sms
            on sms.partition_id = gpm.partition_id
            and sms.sentgen < og.gen
            join dbo.sysmergearticles sma on og.artnick = sma.nickname
            where sma.pubid = sms.pubid

            union all

            select sms.subid
            from #oldgens og
            join dbo.sysmergesubscriptions sms
            on og.gen > @min_sentgen
            and og.genstatus <> 2
            and isnull(sms.partition_id,0) = 0
            and sms.sentgen < og.gen
            join dbo.sysmergearticles sma on og.artnick = sma.nickname
            where sma.pubid = sms.pubid


            union all

            select sms.subid
            from #oldgens og join dbo.MSmerge_generation_partition_mappings gpm
            on og.gen = gpm.generation
            and og.gen > @min_sentgen
            and og.genstatus <> 2
            and gpm.partition_id = -1
            join dbo.sysmergesubscriptions sms
            on sms.sentgen < og.gen
            join dbo.sysmergearticles sma on og.artnick = sma.nickname
            where sma.pubid = sms.pubid

            union all

            select sms.subid
            from #oldgens og join dbo.MSmerge_generation_partition_mappings gpm
            on og.gen = gpm.generation
            and og.gen > @min_sentgen
            and og.genstatus <> 2
            join dbo.sysmergesubscriptions sms
            on sms.sentgen < og.gen
            and sms.partition_id = -1
            join dbo.sysmergearticles sma on og.artnick = sma.nickname
            where sma.pubid = sms.pubid
        ) as sms2

        on sms1.subid = sms2.subid
    end

    return 0
end

 
Last revision 2008RTM
See also

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