你能在 T-SQL 中对存储过程的结果进行选择吗 [英] Can you do a select on the results of a stored procedure in T-SQL

查看:32
本文介绍了你能在 T-SQL 中对存储过程的结果进行选择吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select * from (EXEC sp_SomeStoredProc)

如果您不能这样做,那么是什么阻止了它被添加到 SQL 标准或 T-SQL 中?

解决方案

您不能这样做,但是您可以将其作为插入来执行.例如

插入 mytable执行 myStoredProcedure

此外,永远不要将您的存储过程命名为 sp_xxxx.这是因为在查找用户存储过程之前,由于 sp_,SQL 将始终在系统存储过程区域中进行搜索,从而导致性能上的少量损失,这可能会在频繁运行的进程中增加相当重要.

select * from (EXEC sp_SomeStoredProc)

If you can't do this then what is stopping it from being added to the SQL standard or T-SQL?

解决方案

You can't do this, however you can do it as an insert. e.g.

insert mytable
exec myStoredProcedure

Also, never name your stored procedures sp_xxxx. This is because SQL will always search in the system stored procedure area due to the sp_ before looking in the user stored procedures, leading to a small loss in performance that could add it to be fairly significant on a process that is run frequently.

这篇关于你能在 T-SQL 中对存储过程的结果进行选择吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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