| title | sp_query_store_clear_hints (Transact-SQL) | ||||
|---|---|---|---|---|---|
| description | Removes all Query Store hints for a given query. | ||||
| author | rwestMSFT | ||||
| ms.author | randolphwest | ||||
| ms.date | 07/25/2025 | ||||
| ms.service | sql | ||||
| ms.subservice | system-objects | ||||
| ms.topic | reference | ||||
| ms.custom |
|
||||
| f1_keywords |
|
||||
| helpviewer_keywords |
|
||||
| dev_langs |
|
||||
| monikerRange | =azuresqldb-current || =azuresqldb-mi-current || >=sql-server-ver16 || >=sql-server-linux-ver16 || =fabric-sqldb |
[!INCLUDE sqlserver2022-asdb-asmi-fabricsqldb]
Removes all Query Store hints for a given query ID.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_query_store_clear_hints
[ @query_id = ] query_id
[ , [ @replica_group_id = ] 'replica_group_id' ]
[ ; ]
[!INCLUDE extended-stored-procedures]
The Query Store query_id column from sys.query_store_query. query_id is bigint.
The optional @replica_group_id argument defaults to the local replica (primary or secondary), but you can optionally specify a value matching a value in the replica_group_id column in sys.query_store_replicas to clear a hint for a different replica group. @replica_group_id is bigint.
0 (success) or 1 (failure).
Query Store hints are created by sys.sp_query_store_set_hints.
Requires the ALTER permission on the database.
The following example removes the Query Store hint text for query_id 39:
EXECUTE sys.sp_query_store_clear_hints @query_id = 39;The following example returns existing Query Store hints for query_id 39:
SELECT query_hint_id,
query_id,
replica_group_id,
query_hint_text,
last_query_hint_failure_reason,
last_query_hint_failure_reason_desc,
query_hint_failure_count,
source,
source_desc
FROM sys.query_store_query_hints
WHERE query_id = 39;