May 29, 2012

sp_MSsetgentozero (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_MSsetgentozero(int @tablenick
, uniqueidentifier @rowguid
, tinyint @metatype)

MetaData:

 create procedure sys.sp_MSsetgentozero  
(@tablenick int,
@rowguid uniqueidentifier,
@metatype tinyint= null)
as
declare @retcode int
declare @METADATA_TYPE_Tombstone tinyint
declare @METADATA_TYPE_Contents tinyint
declare @METADATA_TYPE_PartialDelete tinyint
declare @METADATA_TYPE_SystemDelete tinyint

set @METADATA_TYPE_Tombstone= 1
set @METADATA_TYPE_Contents= 2
set @METADATA_TYPE_PartialDelete= 5
set @METADATA_TYPE_SystemDelete= 6

if (@rowguid is null)
begin
RAISERROR(14043, 16, -1, '@rowguid', 'sp_MSsetgentozero')
return (1)
end
if (@tablenick is null)
begin
RAISERROR(14043, 16, -1, '@tablenick', 'sp_MSsetgentozero')
return (1)
end
if (@metatype is not null and
@metatype not in (@METADATA_TYPE_Tombstone,
@METADATA_TYPE_Contents,
@METADATA_TYPE_PartialDelete,
@METADATA_TYPE_SystemDelete))
begin
-- RAISERROR(20052, 16, -1)
return 0
end

-- security check
exec @retcode = sys.sp_MSrepl_PAL_rolecheck @tablenick = @tablenick
if (@retcode <> 0) or (@@error <> 0)
return 1

if @metatype in (@METADATA_TYPE_Tombstone,
@METADATA_TYPE_PartialDelete,
@METADATA_TYPE_SystemDelete)
begin
update dbo.MSmerge_tombstone
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid
end
else if @metatype = @METADATA_TYPE_Contents
begin
update dbo.MSmerge_contents
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid

update dbo.MSmerge_past_partition_mappings
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid
end
else
begin
update dbo.MSmerge_tombstone
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid

if 0 = @@rowcount
begin
update dbo.MSmerge_contents
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid
end

update dbo.MSmerge_past_partition_mappings
set generation = 0
where tablenick = @tablenick and rowguid = @rowguid
end

return 0

No comments:

Post a Comment

Total Pageviews