May 21, 2012

sp_MSlocktable (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_MSlocktable(nvarchar @ownername
, nvarchar @tablename)

MetaData:

 create procedure sys.sp_MSlocktable  
(
@ownername sysname,
@tablename sysname
)
AS
begin
declare @retcode int
,@procname sysname
,@objid int
,@qualified_name nvarchar(300)
,@spretcode int
,@spcall nvarchar(256)

if @ownername is null
set @qualified_name= QUOTENAME(@tablename)
else
set @qualified_name= QUOTENAME(@ownername) + '.' + QUOTENAME(@tablename)

select @objid = object_id(@qualified_name)
if @objid is NULL
select @objid = object_id from sys.objects where name=@tablename
if @objid is null
return (1)

exec @retcode = sys.sp_MSrepl_PAL_rolecheck @objid = @objid
if ((@retcode <> 0) or (@@error <> 0))
return 1

if 1=sys.fn_MSuselightweightreplication(null, null, null, null, null, null, @objid)
begin
--
-- For security: break ownership chain as
-- we have no control over the proc name is
--
select @procname= 'dbo.MSmerge_lws_sp_multi_' + procname_postfix from dbo.sysmergearticles where objid = @objid
and (1 = {fn ISPALUSER(pubid)})
select @spcall = N'exec @p1 = ' + @procname + N' @action = 4 '
exec @retcode = sys.sp_executesql @stmt = @spcall
,@params = N'@p1 int output'
,@p1 = @spretcode output
IF @@ERROR<>0 or @retcode<>0 or @spretcode != 0
RETURN (1)
end
else
begin
--
-- For security: break ownership chain as
-- we have no control over the proc name is
--
select @procname = 'dbo.' + select_proc from dbo.sysmergearticles where objid = @objid
and (1 = {fn ISPALUSER(pubid)})
select @spcall = N'exec @p1 = ' + @procname + N' @maxschemaguidforarticle = NULL, @type = 7 '
exec @retcode = sys.sp_executesql @stmt = @spcall
,@params = N'@p1 int output'
,@p1 = @spretcode output
IF @@ERROR<>0 or @retcode<>0 or @spretcode != 0
RETURN (1)
end
end

No comments:

Post a Comment

Total Pageviews