Skip to content

Latest commit

 

History

History
90 lines (66 loc) · 2.58 KB

sys-sp-query-store-clear-hints-transact-sql.md

File metadata and controls

90 lines (66 loc) · 2.58 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
sp_query_store_clear_hints (Transact-SQL)
Removes all Query Store hints for a given query.
rwestMSFT
randolphwest
03/07/2025
sql
system-objects
reference
sp_query_store_clear_hints_TSQL
sys.sp_query_store_clear_hints_TSQL
sp_query_store_clear_hints
sys.sp_query_store_clear_hints
sys.sp_query_store_clear_hints
sp_query_store_clear_hints
TSQL
=azuresqldb-current || =azuresqldb-mi-current || >=sql-server-ver16 || >=sql-server-linux-ver16

sp_query_store_clear_hints (Transact-SQL)

[!INCLUDE sqlserver2022-asdb-asmi]

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

Syntax

sp_query_store_clear_hints
    [ @query_id = ] query_id
[ ; ]

Arguments

[!INCLUDE extended-stored-procedures]

[ @query_id = ] query_id

The Query Store query_id column from sys.query_store_query. query_id is bigint.

Return value

0 (success) or 1 (failure).

Remarks

Query Store hints are created by sys.sp_query_store_set_hints.

Permissions

Requires the ALTER permission on the database.

Examples

Clear query hint text

The following example removes the Query Store hint text for query_id 39:

EXEC sys.sp_query_store_clear_hints @query_id = 39;

View Query Store hints

The following example returns existing Query Store hints for query_id 39:

SELECT query_hint_id,
    query_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;

Related content