如何从存储过程中选择 [英] How to SELECT FROM stored procedure
问题描述
我有一个返回行的存储过程:
I have a stored procedure that returns rows:
CREATE PROCEDURE MyProc
AS
BEGIN
SELECT * FROM MyTable
END
我的实际过程有点复杂,这就是为什么需要存储过程.
My actual procedure is a little more complicated, which is why a stored procedure is necessary.
是否可以通过调用此过程来选择输出?
Is it possible to select the output by calling this procedure?
类似于:
SELECT * FROM (EXEC MyProc) AS TEMP
我需要使用 SELECT TOP X
、ROW_NUMBER
和一个额外的 WHERE
子句来分页我的数据,但我真的不需要想将这些值作为参数传递.
I need to use SELECT TOP X
, ROW_NUMBER
, and an additional WHERE
clause to page my data, and I don't really want to pass these values as parameters.
推荐答案
You can use a User-defined function or a view instead of a procedure.
一个过程可以返回多个结果集,每个结果集都有自己的架构.不适合在 SELECT
语句中使用.
A procedure can return multiple result sets, each with its own schema. It's not suitable for using in a SELECT
statement.
这篇关于如何从存储过程中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!