question

anthonyk avatar image
anthonyk asked

Where does APPLOCK_TEST live?

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.
lockingprogramming
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Scot Hauder avatar image
Scot Hauder answered
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
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Cyborg avatar image Cyborg commented ·
Scot congrats for 3K!
0 Likes 0 ·
Scot Hauder avatar image Scot Hauder commented ·
Thanks, and you on 4K
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.