在链接服务器中调用用户定义的函数 [英] Call User Defined Functions in Linked Server

查看:68
本文介绍了在链接服务器中调用用户定义的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我解决我在使用链接服务器调用函数时遇到的问题,请通过示例代码说明。



这方面的任何帮助都将是非常感谢。

Can anybody help me with the problem that I am facing while calling functions using linked server, please explain via sample code.

Any help in this regard will be highly appreciated.

推荐答案

无法在链接服务器上调用用户定义的函数。



要解决此问题问题,使用Openquery函数而不是四部分命名约定。



您需要在您的数据库中创建以下函数,其中链接服务器需要调用。



User defined functions cannot be called on Linked Server.

To work around this problem, use the Openquery function instead of the four-part naming convention.

You need to create following function in your DB where Linked Server needs to call.

CREATE FUNCTION [dbo].Function_Name(@Parameter INT)

RETURNS VARCHAR(8000)

AS

BEGIN

DECLARE @word sysname

EXEC LinkedServer.DatabaseName.dbo.sp_executesql

N'SELECT DatabaseName.dbo.Function_Name(@Parameter)' --dynamic sql query to execute

,N'@Parameter int' --parameter definitions

,@Parameter=@word OUTPUT --assigning the caller procs local variable to the dynamic parameter

RETURN @word

END









欲了解更多详情,请访问以下链接。



http://developersmania.blogspot.com/2012/11/call-user-defined- function-on-linked.html [ ^ ]



我希望这可以帮到你。





For more details, kindly visit the link below.

http://developersmania.blogspot.com/2012/11/call-user-defined-function-on-linked.html[^]

I hope this helps you.


这篇关于在链接服务器中调用用户定义的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆