Skip to content

Commit fe6e6c2

Browse files
markingmynamerwestMSFT
authored andcommitted
Actual fix
1 parent 5c774f3 commit fe6e6c2

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

docs/relational-databases/system-stored-procedures/sp-getapplock-transact-sql.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_getapplock places a lock on an application resource.
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 06/23/2025
7+
ms.date: 03/02/2026
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -20,7 +20,7 @@ dev_langs:
2020
- "TSQL"
2121
monikerRange: "=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb"
2222
---
23-
# sp_getapplock (Transact-SQL)
23+
# sys.sp_getapplock (Transact-SQL)
2424

2525
[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-fabricsqldb.md)]
2626

@@ -31,7 +31,7 @@ Places a lock on an application resource.
3131
## Syntax
3232

3333
```syntaxsql
34-
sp_getapplock
34+
sys.sp_getapplock
3535
[ [ @Resource = ] N'Resource' ]
3636
, [ @LockMode = ] 'LockMode'
3737
[ , [ @LockOwner = ] 'LockOwner' ]
@@ -71,11 +71,11 @@ The owner of the lock, which is the *@LockOwner* value when the lock was request
7171

7272
#### [ @LockTimeout = ] *LockTimeout*
7373

74-
A lock time-out value in milliseconds. *@LockTimeout* is **int**, and the default value is the same as the value returned by `@@LOCK_TIMEOUT`. A value of `-1` (default) indicates no time-out period (that is, wait forever). To indicate that a lock request should return a return code of `-1` instead of waiting for the lock when the request can't be granted immediately, specify `0`.
74+
A lock timeout value in milliseconds. *@LockTimeout* is **int**, and the default value is the same as the value returned by `@@LOCK_TIMEOUT`. A value of `-1` (default) indicates no timeout period (that is, wait forever). To indicate that a lock request should return a return code of `-1` instead of waiting for the lock when the request can't be granted immediately, specify `0`.
7575

7676
#### [ @DbPrincipal = ] N'*DbPrincipal*'
7777

78-
The user, role, or application role that's permissions to an object in a database. *@DbPrincipal* is **sysname**, with a default of `public`. The caller of the function must be a member of **database_principal**, **dbo**, or the **db_owner** fixed database role to call the function successfully. The default is **public**.
78+
The user, role, or application role that has permissions to an object in a database. *@DbPrincipal* is **sysname**, with a default of `public`. The caller of the function must be a member of **database_principal**, **dbo**, or the **db_owner** fixed database role to call the function successfully.
7979

8080
## Return code values
8181

@@ -100,16 +100,16 @@ The lock resource created by `sp_getapplock` is created in the current database
100100
- The database principal specified in the *@DbPrincipal* parameter.
101101
- The lock name specified in the @Resource parameter.
102102

103-
Only a member of the database principal specified in the *@DbPrincipal* parameter can acquire application locks that specify that principal. Members of the **dbo** and **db_owner** roles are implicitly considered members of all roles.
103+
Only a member of the database principal specified in the *@DbPrincipal* parameter can acquire application locks that specify that principal. Members of the **dbo** and **db_owner** fixed database roles are implicitly considered members of all roles.
104104

105105
Locks can be explicitly released with `sp_releaseapplock`. When an application calls `sp_getapplock` multiple times for the same lock resource, `sp_releaseapplock` must be called the same number of times to release the lock. When a lock is opened with the `Transaction` lock owner, that lock is released when the transaction is committed or rolled back.
106106

107-
If `sp_getapplock` is called multiple times for the same lock resource, but the lock mode that is specified in any of the requests isn't the same as the existing mode, the effect on the resource is a union of the two lock modes. In most cases, this means the lock mode is promoted to the stronger of the lock modes, the existing mode, or the newly requested mode. This stronger lock mode is held until the lock is ultimately released even if lock release calls occur before that time.
107+
If `sp_getapplock` is called multiple times for the same lock resource, but the lock mode that is specified in any of the requests isn't the same as the existing mode, the effect on the resource is a union of the two lock modes. In most cases, the lock mode is promoted to the stronger of the lock modes, the existing mode, or the newly requested mode. This stronger lock mode is held until the lock is ultimately released even if lock release calls occur before that time.
108108

109109
For example, in the following sequence of calls, the resource is held in `Exclusive` mode instead of in `Shared` mode.
110110

111111
```sql
112-
USE AdventureWorks2022;
112+
USE AdventureWorks2025;
113113
GO
114114

115115
BEGIN TRANSACTION;
@@ -139,7 +139,7 @@ A deadlock with an application lock doesn't roll back the transaction that reque
139139
Here's an example:
140140

141141
```sql
142-
USE AdventureWorks2022;
142+
USE AdventureWorks2025;
143143
GO
144144

145145
BEGIN TRANSACTION;
@@ -171,14 +171,14 @@ Use the `sys.dm_tran_locks` dynamic management view or the `sp_lock` system stor
171171

172172
## Permissions
173173

174-
Requires membership in the **public** role.
174+
Requires membership in the **public** fixed database role.
175175

176176
## Examples
177177

178178
The following example places a shared lock, which is associated with the current transaction, on the resource `Form1` in the [!INCLUDE [sssampledbobject-md](../../includes/sssampledbobject-md.md)] database.
179179

180180
```sql
181-
USE AdventureWorks2022;
181+
USE AdventureWorks2025;
182182
GO
183183

184184
BEGIN TRANSACTION;
@@ -201,7 +201,7 @@ BEGIN TRANSACTION;
201201

202202
EXECUTE sp_getapplock
203203
@DbPrincipal = 'dbo',
204-
@Resource = 'AdventureWorks2022',
204+
@Resource = 'AdventureWorks2025',
205205
@LockMode = 'Shared';
206206

207207
COMMIT TRANSACTION;
@@ -213,4 +213,3 @@ GO
213213
- [APPLOCK_MODE (Transact-SQL)](../../t-sql/functions/applock-mode-transact-sql.md)
214214
- [APPLOCK_TEST (Transact-SQL)](../../t-sql/functions/applock-test-transact-sql.md)
215215
- [sp_releaseapplock (Transact-SQL)](sp-releaseapplock-transact-sql.md)
216-

0 commit comments

Comments
 (0)