Search code examples
sql-serversql-server-2005sql-server-2000distributed-transactionsuser-defined-functions

How do you remotely execute a table valued function in Sql-Server 2000/5?


I have a stored procedure (sql2005) that needs to call a table valued function on a remote server (sql2000).

My query is as follows:

select
    *
from
    mytable mt
     cross apply 
      opendatasource('sqloledb','Data Source=remoteserver;UID=user;Password=pass').mydatabase.dbo.mytvf
      (cast(param1 as numeric(20,0)), @param2, mt.param3) 

I'm getting an incorrect syntax error near 'cast'. Is it possible to execute a tvf with this notation? Should I somehow be using openrowset? Any help is appreciated.


Solution

  • Here's the official word. You cannot call a UDF in this way.

    http://connect.microsoft.com/SQLServer/feedback/details/276758/remote-table-valued-function-calls-are-not-allowed

    Looks like Mircosoft is working on the ability in a future version though.