开发者

Call SP from another SP with result set

开发者 https://www.devze.com 2023-03-12 21:21 出处:网络
I have a stored procedure in which I have called another stored procedure [Let say I have parent stored procedure which is calling child SP]. Child stored procedure have a result set which have almost

I have a stored procedure in which I have called another stored procedure [Let say I have parent stored procedure which is calling child SP]. Child stored procedure have a result set which have almost 10,000 records. How can I get it in the parent stored procedure?

Parent SP 
(
 Student INT
 Teacher INT
 Name Var开发者_Python百科char
)

Child SP [Get Student specific activities] Student

-- Result Set of Child SP needed Here

-- End of Parent SP


One was is to use INSERT... EXECUTE... Within the parent stored procedure, have something like:

CREATE TABLE #Temp (StudentId int null, <Other columns as required>)

INSERT #Temp
 EXECUTE ChildSP

The (single!) data set returned by the child SP must match the table structure of #Temp.


You would store the results of your child stored procedure into a temp table and access those records in the parent stored procedure by selecting from the temp table.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号