SET Not Applied to SELECT When Using a Linked Server
Make sure that the SET
and SELECT
statements are combined in the same query. If you open the connection and only perform the SET
, as shown below, the SET
parameters only get applied for the duration of the connection.
SELECT * FROM OPENQUERY(linkedserver, 'SET SamplingMode=interpolated')
The SamplingMode
option in the previous example does not get applied to the next OPENQUERY
that you perform with a SELECT
statement. The SET
statement only gets applied to the query if it is included with the SELECT
statement. See Use OPENQUERY to Access a Linked Server for examples of how to include the SET
statement with a SELECT
statement.