sp_releaseapplock
Releases a lock on an application resource.
Syntax
sp_releaseapplock [ @Resource = ] 'resource_name'
[ , [ @LockOwner = ] 'lock_owner' ]
Arguments
[@Resource =] 'resource_name'
Is the lock resource name specified by the client application when the lock was requested. resource name is nvarchar(255), with no default.
[@LockOwner =] 'lock_owner'
Is the lock owner and must match the lock_owner value specified when the lock was requested. lock_owner is nvarchar(32), and can be Transaction (the default) or Session.
Return Code Values
>= 0 (success) or < 0 (failure)
Value | Result |
---|---|
0 | Lock was successfully released. |
-999 | Parameter validation or other call error. |
Remarks
If an application calls sp_getapplock multiple times on the same lock resource, sp_releaseapplock must be called the same number of times to release the lock.
When the server shuts down for any reason, the locks are released.
Permissions
Execute permissions default to the public role.
Examples
This example releases the lock associated with the current transaction on the resource Form1 in the Northwind database.
USE Northwind
EXEC sp_releaseapplock @Resource = 'Form1'