This question already has an answer here:
这个问题在这里已有答案:
- SQL Server - SELECT FROM stored procedure 15 answers
SQL Server - SELECT FROM存储过程15答案
How can I achieve something like this :
我怎样才能实现这样的目标:
SELECT * DISTINCT FROM
(execute dbo.MyStoredProcedure(@ID1,@ID2))
suppose that's inside another stored procedure.
假设它在另一个存储过程中。
How can I call a stored procedure from another stored procedure and get the result as a table (my select is intended for that)
如何从另一个存储过程调用存储过程并将结果作为表格获取(我的选择用于此目的)
2 个解决方案
#1
2
Try
DECLARE @TableTemp TABLE (--declare parameters, ouput from SP)
INSERT INTO @TableTemp
EXEC dbo.MyStoredProcedure @ID1,@ID2
SELECT * FROM @TableTemp
#2
1
You can do something like this.
你可以做这样的事情。
INSERT INTO #temp
EXEC MyStoredProcedure(@ID1,@ID2)
SELECT * FROM #temp
#1
2
Try
DECLARE @TableTemp TABLE (--declare parameters, ouput from SP)
INSERT INTO @TableTemp
EXEC dbo.MyStoredProcedure @ID1,@ID2
SELECT * FROM @TableTemp
#2
1
You can do something like this.
你可以做这样的事情。
INSERT INTO #temp
EXEC MyStoredProcedure(@ID1,@ID2)
SELECT * FROM #temp