I have a procedure (A) that produces a table and I would like to create a new procedure (B) that creates a temp table that stores all columns structures and row values produced by procedure (A).
How to do so?
IMPORTANT NOTE: I don't want to create my temp table column by column, becasue the table that procedure (A) changes its structure according to some conditions, as well as any table this procedure (A) produces contains so many columns.
I tried this IN PROCEDURE (b) but it failed:
INSERT INTO #MY_TEMP_TABLE EXEC dbo.MY_OLD_STORED_PROC 'value1','value2','value3','value4'
SELECT COUNT(*) FROM #MY_TEMP_TABLE
The error given is: Invalid object name '#MY_TEMP_TABLE'