Sunday, 15 September 2013

Use Openquery in local WHERE Clause

Use Openquery in local WHERE Clause

I work on SQL Server 2008 R2.
I have a REFERENCE Database on Server_1 that contains a scalar-valued
function MyFunc that takes two params and returns an INT.
I need to build a query on a table MyTable on server_2 based on the result
of MyFunc, like:
SELECT *
FROM MyTable
WHERE MyFunc(MyTable.param1, MyTable.param2) <> 0
I tried using Openquery, but it did not work
SELECT *
FROM MyTable
WHERE OPENQUERY(Server_1,'SELECT REFERENCE.ref.MyFunc(param1, param2)') <> 0
What would be the best way to handle this type of query ? Thanks

No comments:

Post a Comment