This article is a quick outline of a work around to using variables with OpenQuery - as you cannot directly use variables with OpenQuery.
- Author: Lewis Talley
- Published: 07/28/2015
- Applies to: InSQL (10.0 +)
OpenQuery does not support passing variables as shown below in the query that does not work:
The work around is to build your SQL query as a string - including the variables you want to include and then calling the ExecuteSQL stored procedure as shown below: