MS SQL SP - Working with EXEC recordset
-
03-07-2019 - |
Question
Is there a way to work on a recordset returned from an exec within another SP? The whole recordset, preferably not using OUTPUT
I.E.
MyStoredProcedure @var1 int AS BEGIN
EXEC anotherSP @var1
-- do something against the recordset returned by anotherSP
END
Solution
CREATE PROC MyStoredProcedure
@var1 int
AS
BEGIN
DECLARE #temp (
col1 ...
)
INSERT #temp
EXEC anotherSP @var1
-- do something against #temp
END
A table variable also wokrs in SQL 2005 and above. temp tables only for SQL 2000.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow