You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -31,7 +31,7 @@ Places a lock on an application resource.
31
31
## Syntax
32
32
33
33
```syntaxsql
34
-
sp_getapplock
34
+
sys.sp_getapplock
35
35
[ [ @Resource = ] N'Resource' ]
36
36
, [ @LockMode = ] 'LockMode'
37
37
[ , [ @LockOwner = ] 'LockOwner' ]
@@ -71,11 +71,11 @@ The owner of the lock, which is the *@LockOwner* value when the lock was request
71
71
72
72
#### [@LockTimeout = ]*LockTimeout*
73
73
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`.
75
75
76
76
#### [@DbPrincipal = ] N'*DbPrincipal*'
77
77
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.
79
79
80
80
## Return code values
81
81
@@ -100,16 +100,16 @@ The lock resource created by `sp_getapplock` is created in the current database
100
100
- The database principal specified in the *@DbPrincipal* parameter.
101
101
- The lock name specified in the @Resource parameter.
102
102
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.
104
104
105
105
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.
106
106
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.
108
108
109
109
For example, in the following sequence of calls, the resource is held in `Exclusive` mode instead of in `Shared` mode.
110
110
111
111
```sql
112
-
USE AdventureWorks2022;
112
+
USE AdventureWorks2025;
113
113
GO
114
114
115
115
BEGIN TRANSACTION;
@@ -139,7 +139,7 @@ A deadlock with an application lock doesn't roll back the transaction that reque
139
139
Here's an example:
140
140
141
141
```sql
142
-
USE AdventureWorks2022;
142
+
USE AdventureWorks2025;
143
143
GO
144
144
145
145
BEGIN TRANSACTION;
@@ -171,14 +171,14 @@ Use the `sys.dm_tran_locks` dynamic management view or the `sp_lock` system stor
171
171
172
172
## Permissions
173
173
174
-
Requires membership in the **public** role.
174
+
Requires membership in the **public**fixed database role.
175
175
176
176
## Examples
177
177
178
178
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.
0 commit comments