I am looking to perform an APPLOCK_TEST within my .NET program, so I was wondering, what it is and where exactly does it live. By being in all upper case, I suspect it is a function, but I cannot find it. If it is a function then I will have to make an ExecuteScalar call. I don't think it is a stored procedure, so I cannot code calling it like one.
sp_getapplock and sp_releaseapplock are stored procedures. APPLOCK_TEST should be referenced via a SQL SELECT in a string or placed in a stored proc. eg SELECT APPLOCK_TEST('public', 'yourresource', 'Exclusive', 'Transaction') Preferably in a stored proc because you will have to wrap this in a transaction if the lock_owner is set as Transaction per the example. APPLOCK_TEST is a built-in function so there is nothing to view. You can find the lock info in master.sys.syslockinfo where rsc_type=10