Skip to content

Commit 5a75351

Browse files
authored
Merge pull request #34509 from rwestMSFT/rw-0623-stored-procedures-010
System stored procedure refresh - phase 10
2 parents df1315e + 231b9a6 commit 5a75351

File tree

40 files changed

+204
-169
lines changed

40 files changed

+204
-169
lines changed

docs/relational-databases/system-stored-procedures/sp-set-session-context-transact-sql.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_set_session_context sets a key-value pair in the session context
44
author: VanMSFT
55
ms.author: vanto
66
ms.reviewer: randolphwest
7-
ms.date: 03/07/2025
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -69,7 +69,9 @@ The total size of the session context is limited to 1 MB. If you set a value tha
6969
You can monitor overall memory usage by querying [sys.dm_os_memory_cache_counters](../system-dynamic-management-views/sys-dm-os-memory-cache-counters-transact-sql.md) as follows:
7070

7171
```sql
72-
SELECT * FROM sys.dm_os_memory_cache_counters WHERE type = 'CACHESTORE_SESSION_CONTEXT';
72+
SELECT *
73+
FROM sys.dm_os_memory_cache_counters
74+
WHERE type = 'CACHESTORE_SESSION_CONTEXT';
7375
```
7476

7577
## Examples
@@ -79,14 +81,20 @@ SELECT * FROM sys.dm_os_memory_cache_counters WHERE type = 'CACHESTORE_SESSION_C
7981
The following example shows how to set and then return a session's context key named `language`, with a value of `English`.
8082

8183
```sql
82-
EXEC sys.sp_set_session_context @key = N'language', @value = 'English';
84+
EXECUTE sys.sp_set_session_context
85+
@key = N'language',
86+
@value = 'English';
87+
8388
SELECT SESSION_CONTEXT(N'language');
8489
```
8590

8691
The following example demonstrates the use of the optional read-only flag.
8792

8893
```sql
89-
EXEC sys.sp_set_session_context @key = N'user_id', @value = 4, @read_only = 1;
94+
EXECUTE sys.sp_set_session_context
95+
@key = N'user_id',
96+
@value = 4,
97+
@read_only = 1;
9098
```
9199

92100
### B. Set and return a client correlation ID
@@ -96,7 +104,7 @@ The following example shows how to set and retrieve a session context key named
96104
1. Set the value.
97105

98106
```sql
99-
EXEC sp_set_session_context 'client_correlation_id', '12323ad';
107+
EXECUTE sp_set_session_context 'client_correlation_id', '12323ad';
100108
```
101109

102110
1. Retrieve the value.

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_setapprole activates the permissions associated with an applicat
44
author: VanMSFT
55
ms.author: vanto
66
ms.reviewer: randolphwest
7-
ms.date: 08/22/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -95,22 +95,23 @@ Requires membership in **public** and knowledge of the password for the role.
9595

9696
### A. Activate an application role without the encrypt option
9797

98-
The following example activates an application role named `SalesAppRole`, with the plain-text password `AsDeF00MbXX`, created with permissions designed for the application used by the current user.
98+
The following example activates an application role named `SalesAppRole`, created with permissions designed for the application used by the current user. Replace `<password>` with a strong password.
9999

100100
```sql
101-
EXEC sys.sp_setapprole 'SalesApprole', 'AsDeF00MbXX';
101+
EXECUTE sys.sp_setapprole 'SalesApprole', '<password>';
102102
GO
103103
```
104104

105105
### B. Activate an application role with a cookie and then reverting to the original context
106106

107-
The following example activates the `Sales11` application role with password `fdsd896#gfdbfdkjgh700mM`, and creates a cookie. The example returns the name of the current user, and then reverts to the original context by executing `sp_unsetapprole`.
107+
The following example activates the `Sales11` application role, and creates a cookie. The example returns the name of the current user, and then reverts to the original context by executing `sp_unsetapprole`. Replace `<password>` with a strong password.
108108

109109
```sql
110-
DECLARE @cookie VARBINARY(8000);
110+
DECLARE @cookie AS VARBINARY (8000);
111111

112-
EXEC sys.sp_setapprole 'Sales11',
113-
'fdsd896#gfdbfdkjgh700mM',
112+
EXECUTE sys.sp_setapprole
113+
'Sales11',
114+
'<password>',
114115
@fCreateCookie = true,
115116
@cookie = @cookie OUTPUT;
116117
```
@@ -124,7 +125,7 @@ SELECT USER_NAME();
124125
Unset the application role.
125126

126127
```sql
127-
EXEC sys.sp_unsetapprole @cookie;
128+
EXECUTE sys.sp_unsetapprole @cookie;
128129
GO
129130
```
130131

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_setnetname sets the network names in sys.servers to their actual
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 08/21/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -62,11 +62,13 @@ Because linked servers and remote servers reside in the same namespace, they can
6262
In this example, Assume `sqlserv2` is the actual name of the SQL Server instance.
6363

6464
```sql
65-
EXEC sp_addlinkedserver 'sqlserv2';
65+
EXECUTE sp_addlinkedserver 'sqlserv2';
6666
GO
67-
EXEC sp_addserver 'rpcserv2';
67+
68+
EXECUTE sp_addserver 'rpcserv2';
6869
GO
69-
EXEC sp_setnetname 'rpcserv2', 'sqlserv2';
70+
71+
EXECUTE sp_setnetname 'rpcserv2', 'sqlserv2';
7072
```
7173

7274
> [!NOTE]
@@ -83,9 +85,10 @@ The following example shows a typical administrative sequence used on [!INCLUDE
8385
```sql
8486
USE master;
8587
GO
86-
EXEC sp_addserver 'Win_1';
87-
EXEC sp_setnetname 'Win_1', 'Win-1';
88-
EXEC Win_1.master.dbo.sp_who;
88+
89+
EXECUTE sp_addserver 'Win_1';
90+
EXECUTE sp_setnetname 'Win_1', 'Win-1';
91+
EXECUTE Win_1.master.dbo.sp_who;
8992
```
9093

9194
## Related content

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_settriggerorder specifies the AFTER triggers that are fired firs
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -116,7 +116,8 @@ The following example specifies that trigger `uSalesOrderHeader` is the first tr
116116
USE AdventureWorks2022;
117117
GO
118118

119-
EXEC sp_settriggerorder @triggername = 'Sales.uSalesOrderHeader',
119+
EXECUTE sp_settriggerorder
120+
@triggername = 'Sales.uSalesOrderHeader',
120121
@order = 'First',
121122
@stmttype = 'UPDATE';
122123
```
@@ -129,7 +130,8 @@ The following example specifies that trigger `ddlDatabaseTriggerLog` is the firs
129130
USE AdventureWorks2022;
130131
GO
131132

132-
EXEC sp_settriggerorder @triggername = 'ddlDatabaseTriggerLog',
133+
EXECUTE sp_settriggerorder
134+
@triggername = 'ddlDatabaseTriggerLog',
133135
@order = 'First',
134136
@stmttype = 'ALTER_TABLE',
135137
@namespace = 'DATABASE';

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "sp_spaceused displays the number of rows, disk space reserved, and
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -140,8 +140,8 @@ This mode is the default, when no parameters are specified. The following result
140140
| Column name | Data type | Description |
141141
| --- | --- | --- |
142142
| `database_name` | **nvarchar(128)** | Name of the current database. |
143-
| `database_size` | **varchar(18)** | Size of the current database in megabytes. `database_size` includes both data and log files. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of all checkpoint files in the filegroup. |
144-
| `unallocated space` | **varchar(18)** | Space in the database that isn't reserved for database objects. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of the checkpoint files with state `PRECREATED` in the filegroup. |
143+
| `database_size` | **varchar(18)** | Size of the current database in megabytes. `database_size` includes both data and log files. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of all checkpoint files in the filegroup. |
144+
| `unallocated space` | **varchar(18)** | Space in the database that isn't reserved for database objects. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of the checkpoint files with state `PRECREATED` in the filegroup. |
145145

146146
Space used by tables in the database. This result set doesn't reflect memory-optimized tables, as there's no per-table accounting of disk usage:
147147

@@ -165,15 +165,15 @@ If *@objname* is omitted, the value of *@oneresultset* is `1`, and *@include_tot
165165
| Column name | Data type | Description |
166166
| --- | --- | --- |
167167
| `database_name` | **nvarchar(128)** | Name of the current database. |
168-
| `database_size` | **varchar(18)** | Size of the current database in megabytes. `database_size` includes both data and log files. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of all checkpoint files in the filegroup. |
169-
| `unallocated space` | **varchar(18)** | Space in the database that isn't reserved for database objects. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of the checkpoint files with state `PRECREATED` in the filegroup. |
168+
| `database_size` | **varchar(18)** | Size of the current database in megabytes. `database_size` includes both data and log files. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of all checkpoint files in the filegroup. |
169+
| `unallocated space` | **varchar(18)** | Space in the database that isn't reserved for database objects. If the database has a `MEMORY_OPTIMIZED_DATA` filegroup, this value includes the total on-disk size of the checkpoint files with state `PRECREATED` in the filegroup. |
170170
| `reserved` | **varchar(18)** | Total amount of space allocated by objects in the database. |
171171
| `data` | **varchar(18)** | Total amount of space used by data. |
172172
| `index_size` | **varchar(18)** | Total amount of space used by indexes. |
173173
| `unused` | **varchar(18)** | Total amount of space reserved for objects in the database, but not yet used. |
174174
| `xtp_precreated` <sup>1</sup> | **varchar(18)** | Total size of checkpoint files with state `PRECREATED`, in KB. This value counts toward the unallocated space in the database as a whole. Returns `NULL` if the database doesn't have a `MEMORY_OPTIMIZED_DATA` filegroup with at least one container. |
175-
| `xtp_used` <sup>1</sup> | **varchar(18)** | Total size of checkpoint files with states `UNDER CONSTRUCTION`, `ACTIVE`, and `MERGE TARGET`, in KB. This value is the disk space actively used for data in memory-optimized tables. Returns `NULL` if the database doesn't have a `MEMORY_OPTIMIZED_DATA` filegroup with at least one container. |
176-
| `xtp_pending_truncation` <sup>1</sup> | **varchar(18)** | Total size of checkpoint files with state `WAITING_FOR_LOG_TRUNCATION`, in KB. This value is the disk space used for checkpoint files that are awaiting cleanup, once log truncation happens. Returns `NULL` if the database doesn't have a `MEMORY_OPTIMIZED_DATA` filegroup with at least one container. |
175+
| `xtp_used` <sup>1</sup> | **varchar(18)** | Total size of checkpoint files with states `UNDER CONSTRUCTION`, `ACTIVE`, and `MERGE TARGET`, in KB. This value is the disk space actively used for data in memory-optimized tables. Returns `NULL` if the database doesn't have a `MEMORY_OPTIMIZED_DATA` filegroup with at least one container. |
176+
| `xtp_pending_truncation` <sup>1</sup> | **varchar(18)** | Total size of checkpoint files with state `WAITING_FOR_LOG_TRUNCATION`, in KB. This value is the disk space used for checkpoint files that are awaiting cleanup, once log truncation happens. Returns `NULL` if the database doesn't have a `MEMORY_OPTIMIZED_DATA` filegroup with at least one container. |
177177

178178
<sup>1</sup> Only included if *@include_total_xtp_storage* is set to `1`.
179179

@@ -203,7 +203,8 @@ The following example reports disk space information for the `Vendor` table and
203203
```sql
204204
USE AdventureWorks2022;
205205
GO
206-
EXEC sp_spaceused N'Purchasing.Vendor';
206+
207+
EXECUTE sp_spaceused N'Purchasing.Vendor';
207208
GO
208209
```
209210

@@ -214,7 +215,8 @@ The following example summarizes space used in the current database and uses the
214215
```sql
215216
USE AdventureWorks2022;
216217
GO
217-
EXEC sp_spaceused @updateusage = N'TRUE';
218+
219+
EXECUTE sp_spaceused @updateusage = N'TRUE';
218220
GO
219221
```
220222

@@ -226,7 +228,7 @@ The following example summarizes the space used by the remote table associated w
226228
USE StretchedAdventureWorks2022;
227229
GO
228230

229-
EXEC sp_spaceused N'Purchasing.Vendor', @mode = 'REMOTE_ONLY';
231+
EXECUTE sp_spaceused N'Purchasing.Vendor', @mode = 'REMOTE_ONLY';
230232
```
231233

232234
### D. Display space usage information for a database in a single result set
@@ -236,18 +238,20 @@ The following example summarizes space usage for the current database in a singl
236238
```sql
237239
USE AdventureWorks2022;
238240
GO
239-
EXEC sp_spaceused @oneresultset = 1;
241+
242+
EXECUTE sp_spaceused @oneresultset = 1;
240243
```
241244

242245
### E. Display space usage information for a database with at least one MEMORY_OPTIMIZED file group in a single result set
243246

244247
The following example summarizes space usage for the current database with at least one `MEMORY_OPTIMIZED` file group in a single result set.
245248

246249
```sql
247-
USE WideWorldImporters
250+
USE WideWorldImporters;
248251
GO
249252

250-
EXEC sp_spaceused @updateusage = 'FALSE',
253+
EXECUTE sp_spaceused
254+
@updateusage = 'FALSE',
251255
@mode = 'ALL',
252256
@oneresultset = '1',
253257
@include_total_xtp_storage = '1';
@@ -259,10 +263,11 @@ GO
259263
The following example summarizes space usage for a `MEMORY_OPTIMIZED` table object in the current database with at least one `MEMORY_OPTIMIZED` file group.
260264

261265
```sql
262-
USE WideWorldImporters
266+
USE WideWorldImporters;
263267
GO
264268

265-
EXEC sp_spaceused @objname = N'VehicleTemperatures',
269+
EXECUTE sp_spaceused
270+
@objname = N'VehicleTemperatures',
266271
@updateusage = 'FALSE',
267272
@mode = 'ALL',
268273
@oneresultset = '0',

docs/relational-databases/system-stored-procedures/sp-special-columns-100-sql-data-warehouse.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_special_columns_100 returns the optimal set of columns that uniq
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.topic: "reference"
1010
dev_langs:
@@ -105,12 +105,12 @@ None.
105105

106106
Requires `SELECT` permission on the schema.
107107

108-
## Examples: [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE [ssPDW](../../includes/sspdw-md.md)]
108+
## Examples: Azure Synapse Analytics and Analytics Platform System (PDW)
109109

110110
The following example returns information about the column that uniquely identifies rows in the `FactFinance` table in the `AdventureWorks` database.
111111

112112
```sql
113-
EXEC sp_special_columns_100 @table_name = 'FactFinance';
113+
EXECUTE sp_special_columns_100 @table_name = 'FactFinance';
114114
```
115115

116116
## Related content

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_special_columns returns the optimal set of columns that uniquely
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -114,7 +114,8 @@ The following example returns information about the column that uniquely identif
114114
USE AdventureWorks2022;
115115
GO
116116

117-
EXEC sp_special_columns @table_name = 'Department',
117+
EXECUTE sp_special_columns
118+
@table_name = 'Department',
118119
@table_owner = 'HumanResources';
119120
```
120121

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_srvrolepermission displays the permissions of a fixed server rol
44
author: VanMSFT
55
ms.author: vanto
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -77,7 +77,7 @@ Requires membership in the **public** role.
7777
The following query returns the permissions associated with the **sysadmin** fixed server role.
7878

7979
```sql
80-
EXEC sp_srvrolepermission 'sysadmin';
80+
EXECUTE sp_srvrolepermission 'sysadmin';
8181
GO
8282
```
8383

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_start_job instructs the SQL Server Agent to execute a job immedi
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 08/22/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -102,7 +102,7 @@ The following example starts a job named `Weekly Sales Data Backup`.
102102
USE msdb;
103103
GO
104104

105-
EXEC dbo.sp_start_job N'Weekly Sales Data Backup';
105+
EXECUTE dbo.sp_start_job N'Weekly Sales Data Backup';
106106
GO
107107
```
108108

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "The sp_statistics system stored procedure returns a list of all in
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 04/08/2024
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -109,12 +109,12 @@ The `sp_statistics` system stored procedure is equivalent to `SQLStatistics` in
109109

110110
Requires `SELECT` permission on the schema.
111111

112-
## Example: [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE [ssPDW](../../includes/sspdw-md.md)]
112+
## Example: Azure Synapse Analytics and Analytics Platform System (PDW)
113113

114114
The following example returns information about the `DimEmployee` table from the `AdventureWorks` sample database.
115115

116116
```sql
117-
EXEC sp_statistics DimEmployee;
117+
EXECUTE sp_statistics DimEmployee;
118118
```
119119

120120
## Related content

0 commit comments

Comments
 (0)