Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass parameters into distributed query?
Message
From
26/10/2000 20:27:28
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
How to pass parameters into distributed query?
Miscellaneous
Thread ID:
00434966
Message ID:
00434966
Views:
33
Hi!

I have a query:

SELECT * From
OPENROWSET(MyLinkedServer, 'SELECT * FROM tblMyTable WHERE MyField > 01/01/2000')

I run this query for Access databsae. Now I need to replace 01/01/2000 by variable passed to the query, for example:

select @MyVar = '01/01/2000'
SELECT * From
OPENROWSET(MyLinkedServer, 'SELECT * FROM tblMyTable WHERE MyField > ' + @MyVar)

Above does not works, says 'incorrect syntax near '+' '

I cannot use
SELECT * From MyLinkedServer...tblMyTable WHERE MyField > @MyVar

because it queries all rows from linked database table, that is quite large and I want to filter out records just before SQL Server receives result. This have strange performance reasons.

Who knows any workaround?
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Next
Reply
Map
View

Click here to load this message in the networking platform