May 24, 2012

sp_MSneedmergemetadataretentioncleanup (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData


sys.sp_MSneedmergemetadataretentioncleanup(uniqueidentifier @replicaid)


 create procedure sys.sp_MSneedmergemetadataretentioncleanup  
@replicaid uniqueidentifier,
@needcleanup bit output
declare @REPLICA_STATUS_BeforeRestore tinyint
declare @pubid uniqueidentifier
declare @metadatacleanuptime datetime
declare @retcode int

exec @retcode = sys.sp_MSrepl_PAL_rolecheck @repid = @replicaid
if @@error<>0 or @retcode<>0
return 1

set @REPLICA_STATUS_BeforeRestore= 7
set @needcleanup = 0

select @pubid = pubid, @metadatacleanuptime = metadatacleanuptime from dbo.sysmergesubscriptions
where subid=@replicaid and

if @pubid is not null
select @needcleanup= case when
sys.fn_add_units_to_date(-1, retention_period_unit, getdate()) > @metadatacleanuptime
then 1
else 0
from dbo.sysmergepublications
where pubid = @pubid

No comments:

Post a Comment

Total Pageviews