2

I have a query that uses the FORCESEEK hint and runs fine on the server where the database I'm querying lives. If I try to run the same exact query remotely from a different server (targeting the original server), I get the following error:

Msg 7436, Level 16, State 1, Line 4 The query processor could not produce a query plan because FORCESEEK or FORCESCAN hints on table or view 'TableBeingQueried' cannot be used with remote data sources. Remove the hints and resubmit the query.

Example T-SQL:

SELECT DISTINCT Table3.Field5
FROM Server1.Database1.Table1 AS T1
INNER JOIN Server1.Database1.Table2 AS T2 WITH (FORCESEEK) -- Index exists for T2.Field2
    ON T1.Field1 = T2.Field2
INNER JOIN Server1.Database1.Table3 AS T3 WITH (FORCESEEK) -- Index exists for T3.Field3
    ON T2.Field4 = T3.Field3
2

You could use OPENQUERY() to be able to query the linked server and apply FORCESEEK / FORCESCAN hints.

Example:

SELECT * FROM
OPENQUERY(
[Server1],
'SELECT DISTINCT Table3.Field5
FROM Server1.Database1.Table1 AS T1
INNER JOIN Server1.Database1.Table2 AS T2 WITH (FORCESEEK) -- Index exists for T2.Field2
    ON T1.Field1 = T2.Field2
INNER JOIN Server1.Database1.Table3 AS T3 WITH (FORCESEEK) -- Index exists for T3.Field3
    ON T2.Field4 = T3.Field3;');
| improve this answer | |
3

You CANNOT use FROCESCAN or FORCESEEK on remote data sources.

Reference: Hints (Transact-SQL) - Table

The FORCESCAN hint has the following restrictions:

The hint cannot be specified for a remote data source.

When using the FORCESEEK hint (with or without index parameters), consider the following guidelines:

The hint cannot be specified for a remote data source. Error 7377 is returned when FORCESEEK is specified with an index hint and error 8180 is returned when FORCESEEK is used without an index hint.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.