|
Home > Archive > MS SQL Server > January 2006 > OpenQuery with variable
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
OpenQuery with variable
|
|
| Roberto Lo Baido 2006-01-24, 11:23 am |
| I need to do this:
select field1, field2,... from openquery(LinkedServ
erName, 'select * from
tablename where field =' + @myVar)
the problem is that openquery does not admit statement to be composed by
concatted strings...how to solve it?
| |
| Sue Hoegemeier 2006-01-24, 8:23 pm |
| You need to build the entire SQL statement as a string and
then pass that string to an EXEC.
You can find more information and an example in the
following article:
HOW TO: Pass a Variable to a Linked Server Query
http://support.microsoft.com/?id=314520
-Sue
On Tue, 24 Jan 2006 08:52:01 -0800, "Roberto Lo Baido"
< RobertoLoBaido@discu
ssions.microsoft.com> wrote:
>I need to do this:
>select field1, field2,... from openquery(LinkedServ
erName, 'select * from
>tablename where field =' + @myVar)
>
>the problem is that openquery does not admit statement to be composed by
>concatted strings...how to solve it?
|
|
|
|
|