Elliott Berkihiser (10/29/2012)
Re: "OpenQuery does not accept variables" --
This runs fine in my set-up:
Select * from OpenQuery(MyLinkedServer,'Declare @name varchar(50) Set @name=''RemoteDB'' Select * from sys.databases where name=@name')
Note the declaration of the variable within the query statement (and the assignment of a value with double quotes).
In your example, OpenQuery is not 'accepting' a variable. The OpenQuery argument is static, even though it contains a variable.
Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this
If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.
Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.