In a stored procedure, I have an EXEC
statement; I want to store its results into a table.
First I create table parameter as:
DECLARE @MyTable AS TABLE
(
[Item1] INT,
[Item2] DECIMAL
)
Then I try to insert values as:
INSERT INTO @MyTable
EXEC [storedProcedure] @testitem = @testitem
My question: is this the right way to do that? Or do I need to use a dynamic query?
Because I read similar questions like this and they suggest to use a dynamic query.