| title | sp_query_store_reset_exec_stats (Transact-SQL) | ||||
|---|---|---|---|---|---|
| description | Clears the runtime stats for a specific query plan from the Query Store. | ||||
| author | markingmyname | ||||
| ms.author | maghan | ||||
| ms.reviewer | randolphwest | ||||
| ms.date | 11/17/2025 | ||||
| ms.service | sql | ||||
| ms.subservice | system-objects | ||||
| ms.topic | reference | ||||
| ms.custom |
|
||||
| f1_keywords |
|
||||
| helpviewer_keywords |
|
||||
| dev_langs |
|
||||
| monikerRange | =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE sqlserver2016-asdb-asdbmi-fabricsqldb]
Clears the runtime stats for a specific query plan from the Query Store.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_query_store_reset_exec_stats [ @plan_id = ] plan_id
[ ; ]
[!INCLUDE extended-stored-procedures]
The ID of the query plan to be cleared. @plan_id is bigint, with no default.
0 (success) or 1 (failure).
Requires the ALTER permission on the database.
If you enable Query Store for secondary replicas, sp_query_store_reset_exec_stats can only be executed against the primary replica. The procedure's scope applies to the entire replica set. Query Store for secondary replicas is supported starting in [!INCLUDE sssql25-md] and later versions, and in Azure SQL Database. For complete platform support, see Query Store for secondary replicas.
The following example returns information about the queries in the Query Store.
SELECT txt.query_text_id,
txt.query_sql_text,
pl.plan_id,
qry.*
FROM sys.query_store_plan AS pl
INNER JOIN sys.query_store_query AS qry
ON pl.query_id = qry.query_id
INNER JOIN sys.query_store_query_text AS txt
ON qry.query_text_id = txt.query_text_id;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.
EXECUTE sp_query_store_reset_exec_stats 3;