May 15, 2012

sp_MSgetmakegenerationapplock_90 (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


sys.sp_MSgetmakegenerationapplock_90(int @wait_time)


create procedure sys.sp_MSgetmakegenerationapplock_90
@wait_time int,
@lock_acquired int OUTPUT
set nocount on

declare @retcode smallint
declare @lock_resource nvarchar(255)
declare @DbPrincipal sysname

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

select @lock_resource = N'MSinternal_makegeneration_inprogress' +
convert(nvarchar(11), db_id())
if exists (select * from sys.database_principals where name=N'MSmerge_PAL_role' and type = 'R')
select @DbPrincipal = N'MSmerge_PAL_role'
select @DbPrincipal = N'db_owner'

-- If someone else is making generations / has just made one, exit so
-- that we won't deadlock
exec @retcode = sp_getapplock @Resource = @lock_resource,
@LockMode = N'Exclusive',
@LockOwner = N'Session',
@LockTimeout = @wait_time,
@DbPrincipal = @DbPrincipal

if @@error <> 0 or @retcode < 0
select @lock_acquired = 0
select @lock_acquired = 1

return @retcode

No comments:

Post a Comment

Total Pageviews