Showing posts with label thisselect. Show all posts
Showing posts with label thisselect. Show all posts

Friday, March 30, 2012

OpenQuery with variable

I need to do this:
select field1, field2,... from openquery(LinkedServerName, '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?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@.discussions.microsoft.com> wrote:

>I need to do this:
>select field1, field2,... from openquery(LinkedServerName, '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?sql

Wednesday, March 28, 2012

OPENQUERY

HI,

Can we use OPENQUERY with a parameter? Something like this:

SELECT * FROM OPENQUERY(@.SOURCE_SERVER_NAME, 'Select * from dbo.FEED')

Please let me know at the earliest. Thanks a lot,.

Mannu.

Not supported. You need to build dynamic TSQL to run it.

|||Thanks phe...sql

OPENQUERY

HI,

Can we use OPENQUERY with a parameter? Something like this:

SELECT * FROM OPENQUERY(@.SOURCE_SERVER_NAME, 'Select * from dbo.FEED')

Please let me know at the earliest. Thanks a lot,.

Mannu.

Not supported. You need to build dynamic TSQL to run it.

|||Thanks phe...