- Microsoft SQL Server
- System tables
- Procedure
- Views
- Functions
|
sys.sp_MSmark_expired_subscriptions
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
News
|