May 15, 2012

sp_MSgetmetadatabatch90 (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_MSgetmetadatabatch90(uniqueidentifier @pubid
, varbinary @tablenickarray
, varbinary @rowguidarray)

MetaData:

 create procedure sys.sp_MSgetmetadatabatch90  
(
@pubid uniqueidentifier,
@tablenickarray varbinary(2000),
@rowguidarray varbinary(8000)
)
as
declare @tablenick int
declare @tablenicklast int
declare @rowguid uniqueidentifier
declare @type tinyint
declare @retcode smallint
declare @tnlength int
declare @tnoffset int
declare @guidoffset int
declare @procname nvarchar(270)

-- security check
if (1 <> {fn ISPALUSER(@pubid)})
begin
RAISERROR (14126, 11, -1)
return (1)
end

set @tablenicklast = 0
-- initialize offsets and length for walking through arrays
set @tnoffset = 1
set @guidoffset = 1
set @tnlength = datalength(@tablenickarray)

-- walk through arrays and populate temp table
while (@tnoffset < @tnlength)
begin
set @tablenick = substring(@tablenickarray, @tnoffset, 4)
set @rowguid = substring(@rowguidarray, @guidoffset, 16)

if @tablenick <> @tablenicklast
begin
select @procname= 'dbo.' + select_proc from dbo.sysmergearticles where nickname = @tablenick and pubid=@pubid
set @tablenicklast = @tablenick
end

-- the following type in the select proc selects out the metadata
set @type= 12

-- check for row in base table
exec @retcode= @procname @maxschemaguidforarticle = NULL, @type=@type output, @rowguid=@rowguid
if @@error <>0 or @retcode <> 0
begin
return (1)
end

-- bump up offsets for next time through loop
set @tnoffset = @tnoffset + 4
set @guidoffset = @guidoffset + 16
end

return (0)

No comments:

Post a Comment

Total Pageviews