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.
this question and answer relate to the 2000 version of SQL Server. In later versions, the restriction on INSERT INTO @table_variable ... EXEC ... were lifted and so it doesn't apply for those later versions.