在表值函数内执行存储过程 [英] Executing stored procedure inside table valued function
本文介绍了在表值函数内执行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在表值函数内部获取存储过程的结果,我可以在SQL Server 2005中实现这一点吗?
我必须要做类似的事情,请参见下面的代码:
Hi,
I have to get stored procedure''s result inside table valued function, can i achieve this in SQL Server 2005 ?
I have to do something like this, Please see code below :
CREATE FUNCTION Test()
RETURNS TABLE AS
RETURN
(
exec 'sp_who'
)
在此先谢谢您,
Rahul
Thanks in advanced,
Rahul
推荐答案
使用此查询从存储过程中选择数据:
Use this query to select data from a stored procedure :
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
SELECT * FROM OPENROWSET('SQLNCLI', 'Server=servername\SQLEXPRESS;Trusted_Connection=yes;',
'EXEC dbname.dbo.sp_who')
您甚至可以将参数发送到该存储过程.
希望对您有所帮助.
You can even send parameters to that stored procedure.
Hope it helps.
不,不可能.
您必须将过程重写为用户定义的函数.
更多帮助 [
No, its not possible.
You have to rewrite your procedure to user defined function.
More help[^]
这篇关于在表值函数内执行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文