如何使用SQL Server 2008在函数中调用Sproc [英] How to call sproc in function using sql server 2008
本文介绍了如何使用SQL Server 2008在函数中调用Sproc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在SQL Server 2008中的用户定义函数中调用存储过程.
我的存储过程还在其中创建了临时表,因此有可能在用户定义的函数中调用此存储过程.
谢谢.
Hi ,
How to call a sproc in user defined function in sql server 2008..
my sproc is also creating temp table inside it , so is it possible call this sproc in user defined function..
Thanks in Adv.
推荐答案
您无法更改函数内部的数据库状态,因此设计禁止从函数调用存储过程.
老实说,可以使用例如OPENQUERY来绕过此限制".有关更多信息,请参见: http://msdn.microsoft.com/zh-CN -us/library/aa175782(v = sql.80).aspx [
You cannot change the database state inside a function so calling a stored procedure from a function is prohibited by design.
To be honest this ''limitation'' can be bypassed using for example OPENQUERY. For more information, see: http://msdn.microsoft.com/en-us/library/aa175782(v=sql.80).aspx[^].
But again I wouldn''t suggest this. Instead finding another (preferrably a single, set based) way to fetch whatever the sp does is the primary goal.
这篇关于如何使用SQL Server 2008在函数中调用Sproc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文