April 22, 2012

sp_flush_commit_table (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_flush_commit_table(bigint @flush_ts
, bigint @cleanup_version)

MetaData:

   
CREATE PROC sys.sp_flush_commit_table (@flush_ts BIGINT, @cleanup_version BIGINT = NULL, @rowcount INT OUTPUT, @date_cleanedup DATETIME OUTPUT) AS
BEGIN
DECLARE @cleanup_ts BIGINT
SET @cleanup_ts = change_tracking_hardened_cleanup_version ()

IF @cleanup_ts > @cleanup_version
SET @cleanup_ts = @cleanup_version

DECLARE @start_ts BIGINT
SET @start_ts = (SELECT MAX(commit_ts) FROM sys.syscommittab)

IF @start_ts IS NULL OR @start_ts < @cleanup_ts
SET @start_ts = @cleanup_ts

INSERT sys.syscommittab
SELECT *
FROM OpenRowset (table SYSCOMMITTABLE, db_id (), @start_ts, 1)
WHERE commit_ts <= @flush_ts

IF @@ROWCOUNT > 10000
SET @rowcount = @@ROWCOUNT
ELSE
SET @rowcount = 10000

DELETE TOP(@rowcount) sys.syscommittab WHERE commit_ts < @cleanup_ts
SET @rowcount = @@ROWCOUNT

select @date_cleanedup=min(commit_time) from sys.syscommittab where commit_ts = (select min(commit_ts) from sys.syscommittab)

IF (@date_cleanedup is null)
SET @date_cleanedup = GETUTCDATE()

END

No comments:

Post a Comment

Total Pageviews