Since this can not be done like :
select * from (call my_stored_procedure(params));
Is there any alternative for the above statement ?
A procedure could return multiple result sets, each with its own schema. It's not suitable for using in a SELECT statement.
User-defined function could be an option. Here's an example:
CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters
(@CubeLength decimal(4,1), @CubeWidth decimal(4,1),@CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( @CubeLength * @CubeWidth * @CubeHeight )
END
more on this link : http://msdn.microsoft.com/en-us/library/aa175085%28SQL.80%29.aspx
Create a temporary table variable and insert sp values into it, like :
Declare @t table
(
--column numbers will be equals to the numbers return by SP
)
Insert Into @t
call my_stored_procedure(params)
Select * From @t
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.