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

Definition:

sys.sp_MScheck_tran_retention(varbinary @xact_seqno
, int @agent_id)

MetaData:

 CREATE PROCEDURE sys.sp_MScheck_tran_retention  
(
@xact_seqno varbinary(16),
@agent_id int
)
as
begin
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
begin
return (1)
end

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
else
select @expired = 1

select N'expired' = @expired
end

No comments:

Post a Comment

Total Pageviews