May 8, 2012

sp_MScheck_tran_retention (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_MScheck_tran_retention(varbinary @xact_seqno
, int @agent_id)


 CREATE PROCEDURE sys.sp_MScheck_tran_retention  
@xact_seqno varbinary(16),
@agent_id int
set nocount on

declare @retcode tinyint
declare @date datetime
declare @retention int
declare @expired int
declare @publisher_database_id int

-- Security Check
exec @retcode = sys.sp_MScheck_pull_access @agent_id = @agent_id, -- agent id
@agent_type = 0 -- only called by distribution agent
if @@error <> 0 or @retcode <> 0
return (1)

select @publisher_database_id = publisher_database_id from MSdistribution_agents
where id = @agent_id

select @date = entry_time from MSrepl_transactions where
xact_seqno = @xact_seqno and
publisher_database_id = @publisher_database_id

select @retention = max_distretention from msdb..MSdistributiondbs where
name = db_name()

if (@date is not null and datediff(minute, @date, getdate()) < @retention*60) or
-- For 'sync with backup' dist db where
-- the dist db might be restored to a previous version so that the subscriber's
-- xact_seqno is larger.
(@date is null and not exists (select * from MSrepl_transactions where
xact_seqno >= @xact_seqno and
publisher_database_id = @publisher_database_id))
select @expired = 0
select @expired = 1

select N'expired' = @expired

No comments:

Post a Comment

Total Pageviews