Skip to content

Commit f6a580e

Browse files
authored
Merge pull request #34508 from rwestMSFT/rw-0623-stored-procedures-009
System stored procedure refresh - phase 9
2 parents 9cde570 + 80255c9 commit f6a580e

File tree

40 files changed

+332
-308
lines changed

40 files changed

+332
-308
lines changed

docs/relational-databases/system-stored-procedures/sp-purge-jobhistory-elastic-jobs-transact-sql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: jobs.sp_purge_jobhistory removes the history records for a job crea
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: randolphwest
7-
ms.date: 08/22/2024
7+
ms.date: 06/23/2025
88
ms.service: azure-sql-database
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -74,7 +74,7 @@ Connect to the `job_database` and run the following command:
7474
--Connect to the job database specified when creating the job agent
7575

7676
-- Delete history of a specific job's executions older than the specified date
77-
EXEC jobs.sp_purge_jobhistory
77+
EXECUTE jobs.sp_purge_jobhistory
7878
@job_name = 'ResultPoolsJob',
7979
@oldest_date = '2016-07-01 00:00:00';
8080
GO
@@ -90,7 +90,7 @@ Connect to the `job_database` and run the following command:
9090
--Connect to the job database specified when creating the job agent
9191

9292
--Delete a job and all its history
93-
EXEC jobs.sp_delete_job @job_name = 'ResultsPoolsJob';
93+
EXECUTE jobs.sp_delete_job @job_name = 'ResultsPoolsJob';
9494
```
9595

9696
## Related content

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: sp_purge_jobhistory removes the history records for a job in the SQ
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"
@@ -85,8 +85,7 @@ The following example removes the history for a job named `NightlyBackups`.
8585
USE msdb;
8686
GO
8787

88-
EXEC dbo.sp_purge_jobhistory
89-
@job_name = N'NightlyBackups';
88+
EXECUTE dbo.sp_purge_jobhistory @job_name = N'NightlyBackups';
9089
GO
9190
```
9291

@@ -100,7 +99,7 @@ The following example executes the procedure with no parameters to remove all hi
10099
USE msdb;
101100
GO
102101

103-
EXEC dbo.sp_purge_jobhistory;
102+
EXECUTE dbo.sp_purge_jobhistory;
104103
GO
105104
```
106105

docs/relational-databases/system-stored-procedures/sp-query-store-clear-message-queues-transact-sql.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Clears all queued (non-persisted) Query Store messages pending for
44
author: markingmyname
55
ms.author: maghan
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"
@@ -22,7 +22,7 @@ monikerRange: ">=sql-server-ver16 || >=sql-server-linux-ver16"
2222

2323
[!INCLUDE [sqlserver2022](../../includes/applies-to-version/sqlserver2022.md)]
2424

25-
Clears all queued (non-persisted) Query Store messages pending for the replica against which the command is executed. `sp_query_store_clear_message_queues` is used when [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md) has been enabled.
25+
Clears all queued (non-persisted) Query Store messages pending for the replica against which the command is executed. `sp_query_store_clear_message_queues` is used when [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md) has been enabled.
2626

2727
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
2828

@@ -50,13 +50,13 @@ Requires the ALTER permission on the database.
5050
The following example clears all queued (non-persisted) Query Store messages pending. The action applies to the replica against which the command is executed.
5151

5252
```sql
53-
EXEC sp_query_store_clear_message_queues;
53+
EXECUTE sp_query_store_clear_message_queues;
5454
```
5555

5656
## Related content
5757

5858
- [Monitor performance by using the Query Store](../performance/monitoring-performance-by-using-the-query-store.md)
59-
- [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md)
59+
- [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md)
6060
- [sys.database_query_store_internal_state (Transact-SQL)](../system-catalog-views/sys-database-query-store-internal-state-transact-sql.md)
6161
- [Query Store catalog views (Transact-SQL)](../system-catalog-views/query-store-catalog-views-transact-sql.md)
6262
- [Query Store stored procedures (Transact-SQL)](query-store-stored-procedures-transact-sql.md)

docs/relational-databases/system-stored-procedures/sp-query-store-flush-db-transact-sql.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Flushes the in-memory portion of the Query Store data to disk."
44
author: markingmyname
55
ms.author: maghan
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"
@@ -45,7 +45,7 @@ None.
4545

4646
## Remarks
4747

48-
If [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md) is enabled, when `sys.sp_query_store_flush_db` is executed on a secondary replica, that secondary replica's cache is forced to flush to the cache on the primary replica. This can accelerate the Query Store cache data being synced to the primary replica, if the secondary replica cache flush is otherwise delayed under heavy workload.
48+
If [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md) is enabled, when `sys.sp_query_store_flush_db` is executed on a secondary replica, that secondary replica's cache is forced to flush to the cache on the primary replica. This can accelerate the Query Store cache data being synced to the primary replica, if the secondary replica cache flush is otherwise delayed under heavy workload.
4949

5050
## Permissions
5151

@@ -56,13 +56,13 @@ Requires the ALTER permission on the database.
5656
The following example flushes the in-memory portion of the Query Store data to disk.
5757

5858
```sql
59-
EXEC sp_query_store_flush_db;
59+
EXECUTE sp_query_store_flush_db;
6060
```
6161

6262
## Related content
6363

6464
- [Monitor performance by using the Query Store](../performance/monitoring-performance-by-using-the-query-store.md)
65-
- [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md)
65+
- [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md)
6666
- [sp_query_store_force_plan (Transact-SQL)](sp-query-store-force-plan-transact-sql.md)
6767
- [sp_query_store_remove_query (Transact-SQL)](sp-query-store-remove-query-transact-sql.md)
6868
- [sp_query_store_unforce_plan (Transact-SQL)](sp-query-store-unforce-plan-transact-sql.md)

docs/relational-databases/system-stored-procedures/sp-query-store-force-plan-transact-sql.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Enables forcing a particular plan for a particular query in the Qu
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: randolphwest
7-
ms.date: 03/19/2025
7+
ms.date: 06/23/2025
88
ms.service: sql
99
ms.subservice: system-objects
1010
ms.topic: "reference"
@@ -59,7 +59,7 @@ Indicates whether optimized plan forcing should be disabled. *@disable_optimized
5959

6060
#### [ @force_plan_scope = ] '*replica_group_id*'
6161

62-
You can force plans on a secondary replica when [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md) is enabled. Execute `sp_query_store_force_plan` and `sp_query_store_unforce_plan` on the primary replica. Using the *@force_plan_scope* argument defaults to the local replica where the command is being executed, but you can specify a *replica_group_id* referencing the [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md) system catalog view.
62+
You can force plans on a secondary replica when [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md) is enabled. Execute `sp_query_store_force_plan` and `sp_query_store_unforce_plan` on the primary replica. Using the *@force_plan_scope* argument defaults to the local replica where the command is being executed, but you can specify a *replica_group_id* referencing the [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md) system catalog view.
6363

6464
## Return code values
6565

@@ -81,33 +81,33 @@ The following example returns information about the queries in the Query Store.
8181

8282
```sql
8383
SELECT txt.query_text_id,
84-
txt.query_sql_text,
85-
pl.plan_id,
86-
qry.*
84+
txt.query_sql_text,
85+
pl.plan_id,
86+
qry.*
8787
FROM sys.query_store_plan AS pl
88-
INNER JOIN sys.query_store_query AS qry
89-
ON pl.query_id = qry.query_id
90-
INNER JOIN sys.query_store_query_text AS txt
91-
ON qry.query_text_id = txt.query_text_id;
88+
INNER JOIN sys.query_store_query AS qry
89+
ON pl.query_id = qry.query_id
90+
INNER JOIN sys.query_store_query_text AS txt
91+
ON qry.query_text_id = txt.query_text_id;
9292
```
9393

9494
After you identify the *query_id* and *plan_id* that you want to force, use the following example to force the query to use a plan.
9595

9696
```sql
97-
EXEC sp_query_store_force_plan
97+
EXECUTE sp_query_store_force_plan
9898
@query_id = 3,
9999
@plan_id = 3;
100100
```
101101

102-
Use [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md), joined with [sys.query_store_replicas](../system-catalog-views/sys-query-store-replicas.md), to retrieve [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md).
102+
Use [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md), joined with [sys.query_store_replicas](../system-catalog-views/sys-query-store-replicas.md), to retrieve [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md).
103103

104104
```sql
105105
SELECT query_plan
106106
FROM sys.query_store_plan AS qsp
107-
INNER JOIN sys.query_store_plan_forcing_locations AS pfl
108-
ON pfl.query_id = qsp.query_id
109-
INNER JOIN sys.query_store_replicas AS qsr
110-
ON qsr.replica_group_id = qsp.replica_group_id
107+
INNER JOIN sys.query_store_plan_forcing_locations AS pfl
108+
ON pfl.query_id = qsp.query_id
109+
INNER JOIN sys.query_store_replicas AS qsr
110+
ON qsr.replica_group_id = qsp.replica_group_id
111111
WHERE qsr.replica_name = 'yourSecondaryReplicaName';
112112
```
113113

docs/relational-databases/system-stored-procedures/sp-query-store-remove-plan-transact-sql.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Removes a single plan from the Query Store."
44
author: markingmyname
55
ms.author: maghan
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"
@@ -57,20 +57,20 @@ The following example returns information about the queries in the Query Store.
5757

5858
```sql
5959
SELECT txt.query_text_id,
60-
txt.query_sql_text,
61-
pl.plan_id,
62-
qry.*
60+
txt.query_sql_text,
61+
pl.plan_id,
62+
qry.*
6363
FROM sys.query_store_plan AS pl
64-
INNER JOIN sys.query_store_query AS qry
65-
ON pl.query_id = qry.query_id
66-
INNER JOIN sys.query_store_query_text AS txt
67-
ON qry.query_text_id = txt.query_text_id;
64+
INNER JOIN sys.query_store_query AS qry
65+
ON pl.query_id = qry.query_id
66+
INNER JOIN sys.query_store_query_text AS txt
67+
ON qry.query_text_id = txt.query_text_id;
6868
```
6969

7070
After you identify the *plan_id* that you want to delete, use the following example to delete a query plan.
7171

7272
```sql
73-
EXEC sp_query_store_remove_plan 3;
73+
EXECUTE sp_query_store_remove_plan 3;
7474
```
7575

7676
## Related content

docs/relational-databases/system-stored-procedures/sp-query-store-remove-query-transact-sql.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "sp_query_store_remove_query (Transact-SQL)"
44
author: markingmyname
55
ms.author: maghan
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"
@@ -57,20 +57,20 @@ The following example returns information about the queries in the Query Store.
5757

5858
```sql
5959
SELECT txt.query_text_id,
60-
txt.query_sql_text,
61-
pl.plan_id,
62-
qry.*
60+
txt.query_sql_text,
61+
pl.plan_id,
62+
qry.*
6363
FROM sys.query_store_plan AS pl
64-
INNER JOIN sys.query_store_query AS qry
65-
ON pl.query_id = qry.query_id
66-
INNER JOIN sys.query_store_query_text AS txt
67-
ON qry.query_text_id = txt.query_text_id;
64+
INNER JOIN sys.query_store_query AS qry
65+
ON pl.query_id = qry.query_id
66+
INNER JOIN sys.query_store_query_text AS txt
67+
ON qry.query_text_id = txt.query_text_id;
6868
```
6969

7070
After you identify the *query_id* that you want to delete, use the following example to delete the query.
7171

7272
```sql
73-
EXEC sp_query_store_remove_query 3;
73+
EXECUTE sp_query_store_remove_query 3;
7474
```
7575

7676
## Related content

docs/relational-databases/system-stored-procedures/sp-query-store-reset-exec-stats-transact-sql.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Clears the runtime stats for a specific query plan from the Query
44
author: markingmyname
55
ms.author: maghan
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"
@@ -57,20 +57,20 @@ The following example returns information about the queries in the Query Store.
5757

5858
```sql
5959
SELECT txt.query_text_id,
60-
txt.query_sql_text,
61-
pl.plan_id,
62-
qry.*
60+
txt.query_sql_text,
61+
pl.plan_id,
62+
qry.*
6363
FROM sys.query_store_plan AS pl
64-
INNER JOIN sys.query_store_query AS qry
65-
ON pl.query_id = qry.query_id
66-
INNER JOIN sys.query_store_query_text AS txt
67-
ON qry.query_text_id = txt.query_text_id;
64+
INNER JOIN sys.query_store_query AS qry
65+
ON pl.query_id = qry.query_id
66+
INNER JOIN sys.query_store_query_text AS txt
67+
ON qry.query_text_id = txt.query_text_id;
6868
```
6969

7070
After you identify the *plan_id* that you want to clear the statistics, use the following example to delete the execution stats for a specific query plan. This example deletes the execution stats for plan number 3.
7171

7272
```sql
73-
EXEC sp_query_store_reset_exec_stats 3;
73+
EXECUTE sp_query_store_reset_exec_stats 3;
7474
```
7575

7676
## Related content

docs/relational-databases/system-stored-procedures/sp-query-store-unforce-plan-transact-sql.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Enables unforcing a previously forced plan for a particular query
44
author: markingmyname
55
ms.author: maghan
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"
@@ -52,7 +52,7 @@ The ID of the query plan that will no longer be enforced. *@plan_id* is **bigint
5252

5353
#### [ @force_plan_scope = ] '*replica_group_id*'
5454

55-
You can unforce plans on a secondary replica when [Query Store for secondary replicas](../performance/query-store-for-secondary-replicas.md) is enabled. Execute `sp_query_store_force_plan` and `sp_query_store_unforce_plan` on the primary replica. Using the *@force_plan_scope* argument defaults to the local replica where the command is being executed, but you can specify a *replica_group_id* referencing the [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md) system catalog view.
55+
You can unforce plans on a secondary replica when [Query Store for readable secondaries](../performance/query-store-for-secondary-replicas.md) is enabled. Execute `sp_query_store_force_plan` and `sp_query_store_unforce_plan` on the primary replica. Using the *@force_plan_scope* argument defaults to the local replica where the command is being executed, but you can specify a *replica_group_id* referencing the [sys.query_store_plan_forcing_locations](../system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql.md) system catalog view.
5656

5757
## Return code values
5858

@@ -68,20 +68,20 @@ The following example returns information about the queries in the Query Store.
6868

6969
```sql
7070
SELECT txt.query_text_id,
71-
txt.query_sql_text,
72-
pl.plan_id,
73-
qry.*
71+
txt.query_sql_text,
72+
pl.plan_id,
73+
qry.*
7474
FROM sys.query_store_plan AS pl
75-
INNER JOIN sys.query_store_query AS qry
76-
ON pl.query_id = qry.query_id
77-
INNER JOIN sys.query_store_query_text AS txt
78-
ON qry.query_text_id = txt.query_text_id;
75+
INNER JOIN sys.query_store_query AS qry
76+
ON pl.query_id = qry.query_id
77+
INNER JOIN sys.query_store_query_text AS txt
78+
ON qry.query_text_id = txt.query_text_id;
7979
```
8080

8181
After you identify the *query_id* and *plan_id* that you want to unforce, use the following example to unforce the plan.
8282

8383
```sql
84-
EXEC sp_query_store_unforce_plan 3, 3;
84+
EXECUTE sp_query_store_unforce_plan 3, 3;
8585
```
8686

8787
## Related content

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Causes stored procedures, triggers, and user-defined functions to
44
author: markingmyname
55
ms.author: maghan
66
ms.reviewer: wiassaf, 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"
@@ -72,7 +72,8 @@ The following example causes stored procedures, triggers, and user-defined funct
7272
```sql
7373
USE AdventureWorks2022;
7474
GO
75-
EXEC sp_recompile N'Sales.Customer';
75+
76+
EXECUTE sp_recompile N'Sales.Customer';
7677
GO
7778
```
7879

0 commit comments

Comments
 (0)