Skip to content
Microsoft SQL Server

SQL Server Error 8622

Query processor could not produce a query plan because of the hints

Applies to: All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last technically reviewed 24 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 8622, Level 16, State 1, Line 1
Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.
Other forms of this message
Related: a USE PLAN hint that cannot be applied (error 8698, catalogue text)
Query processor could not produce query plan because USE PLAN hint contains plan that could not be verified to be legal for query. Remove or replace USE PLAN hint. For best likelihood of successful plan forcing, verify that the plan provided in the USE PLAN hint is one generated automatically by SQL Server for the same query.
Error number
8622
Severity
16 (user-correctable error)
State
1
Product
Microsoft SQL Server Database Engine
Versions
All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last reviewed
24 October 2026

What it means

Error 8622 means the hints on a query (table, join or query hints, or SET FORCEPLAN) demand a plan shape that cannot exist for that query, so the Query Optimizer gives up instead of ignoring them.

Hints are orders, not suggestions. If you force an index seek, the optimiser must find an index whose key matches a predicate; if you force a hash or merge join, the join must have at least one equality condition. When no valid plan satisfies every hint at once, SQL Server stops at compile time with 8622 at level 16. Nothing runs, so no data is changed.

The message does not say which hint is impossible. Look for WITH (FORCESEEK), WITH (INDEX(...)), join hints such as INNER HASH JOIN, query hints in OPTION (...), and SET FORCEPLAN ON earlier in the session. Hints can also come from outside the query text: a plan guide or a Query Store hint attached to the query applies them without being visible in the code.

Common causes

  • FORCESEEK on a table that has no index, or whose indexes do not start with a column used in an equality or range predicate.
  • A HASH JOIN or MERGE JOIN hint on a join whose only conditions are inequalities (>, <, <>).
  • An index hint combined with FORCESEEK on an index that cannot seek for this predicate, or an index that was changed since the hint was written.
  • A plan guide or Query Store hint created for an older version of the query or schema, which no longer fits.
  • Several hints that contradict each other, possibly together with SET FORCEPLAN ON, which fixes the join order.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

Which indexes and key columns does the table have?

SELECT i.name AS index_name, i.type_desc, ic.key_ordinal, c.name AS column_name
FROM sys.indexes AS i
LEFT JOIN sys.index_columns AS ic
       ON ic.object_id = i.object_id AND ic.index_id = i.index_id AND ic.key_ordinal > 0
LEFT JOIN sys.columns AS c
       ON c.object_id = ic.object_id AND c.column_id = ic.column_id
WHERE i.object_id = OBJECT_ID(N'dbo.Orders')
ORDER BY i.index_id, ic.key_ordinal;
What to look for

A seek needs an index whose first key column appears in the WHERE or join condition. A single HEAP row means no index exists at all, so FORCESEEK can never work.

Are plan guides attached in this database?

SELECT name, scope_type_desc, is_disabled, hints, query_text
FROM sys.plan_guides;
What to look for

An enabled plan guide whose query_text matches the failing statement adds the hints in hints, even though they are not in your code.

Are Query Store hints set?

SELECT h.query_id, h.query_hint_text, h.last_query_hint_failure_reason_desc,
       h.query_hint_failure_count, t.query_sql_text
FROM sys.query_store_query_hints AS h
JOIN sys.query_store_query AS q ON q.query_id = h.query_id
JOIN sys.query_store_query_text AS t ON t.query_text_id = q.query_text_id;
What to look for

On SQL Server 2022 and later, a Query Store hint can force hints on a query. A non-zero query_hint_failure_count shows hints that could not be applied.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Run the query without the hint to confirm the cause

Read-only

Remove one hint at a time and compile again. The query that works without a hint shows the plan the optimiser actually chooses; check whether the hint is still needed at all.

SELECT order_id, total
FROM dbo.Orders
WHERE total > 100;   -- no FORCESEEK

Give FORCESEEK an index it can use

Changes schema

If a seek is really wanted, create an index that starts with the filtered column. Test the effect on write performance and storage first.

CREATE INDEX IX_Orders_total ON dbo.Orders (total) INCLUDE (customer_id);

Use a join hint that suits the join condition

Read-only

Hash and merge joins need an equality condition. For a join on inequalities only, let the optimiser choose, or use LOOP JOIN, the only physical join that can evaluate any condition.

SELECT o.order_id, c.name
FROM dbo.Orders AS o
JOIN dbo.Customers AS c ON o.customer_id > c.customer_id
OPTION (LOOP JOIN);

Remove an outdated plan guide or Query Store hint

Changes configuration

If the hint comes from a plan guide or Query Store hint, drop or replace it so it matches the current query and schema.

EXEC sys.sp_query_store_clear_hints @query_id = 42;
-- or, for a plan guide:
EXEC sys.sp_control_plan_guide N'DROP', N'PG_Orders_ForceSeek';

Examples

FORCESEEK on a table without an index

SET NOCOUNT ON;
CREATE TABLE dbo.Customers (customer_id INT NOT NULL, name VARCHAR(50));   -- a heap
INSERT INTO dbo.Customers VALUES (1, 'Sara'), (2, 'Ali');

SELECT name FROM dbo.Customers WITH (FORCESEEK) WHERE customer_id = 2;
Result
Msg 8622, Level 16, State 1, Line 5
Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

FORCESEEK on a column that is not an index key

SET NOCOUNT ON;
CREATE TABLE dbo.Orders (order_id INT PRIMARY KEY, customer_id INT, total DECIMAL(10,2));
INSERT INTO dbo.Orders VALUES (1, 1, 50.00), (2, 2, 250.00);

-- The only index is on order_id
SELECT order_id FROM dbo.Orders WITH (FORCESEEK) WHERE total > 100;
Result
Msg 8622, Level 16, State 1, Line 6
Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

HASH JOIN hint on a join with only an inequality

SET NOCOUNT ON;
CREATE TABLE dbo.Customers (customer_id INT PRIMARY KEY, name VARCHAR(50));
CREATE TABLE dbo.Orders (order_id INT PRIMARY KEY, customer_id INT);
INSERT INTO dbo.Customers VALUES (1, 'Sara'), (2, 'Ali');
INSERT INTO dbo.Orders VALUES (1, 1), (2, 2);

SELECT o.order_id, c.name
FROM dbo.Orders AS o
JOIN dbo.Customers AS c ON o.customer_id > c.customer_id
OPTION (HASH JOIN);
Result
Msg 8622, Level 16, State 1, Line 7
Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

How to prevent it

Use hints sparingly and document why each one exists, next to the query. Re-test hinted queries after index changes, because dropping or changing an index can make a FORCESEEK or index hint impossible. Keep a list of plan guides and Query Store hints and review it after schema deployments.

Prefer fixing the root cause (statistics, indexes, query shape) over forcing plans; see the advanced query optimisation lesson.

Common questions

Why does SQL Server not just ignore a hint it cannot follow?

Table, join and query hints are binding. Rather than silently running a plan you did not ask for, SQL Server refuses to compile the statement and tells you the hints are the problem.

My query has no hints at all. Why do I get 8622?

Hints can be added from outside: a plan guide, a Query Store hint, or SET FORCEPLAN ON earlier in the same session. Check sys.plan_guides and sys.query_store_query_hints.

Is LOOP JOIN always possible?

A nested loops join can evaluate any join condition, so it is the safe choice for inequality joins, but forcing it on large inputs can be very slow. Removing the hint is usually better.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.