Is there a way to insert results from a stored procedure into a table variable. The following does not work.
(sp is a stored procedure with one numeric parameter)
declare @sql as nvarchar(200)
declare @tablevar table
(a Char(10),
b int,
c Numeric(5,2),
d Numeric(5,2))
set @sql = 'insert into '+ @tablevar + ' exec sp 2002'
exec sp_executesql @sql
I pretty sure a table variable is not available in the dynamic sql. Any other idea's on how to get the results of a sp inserted into a table variable?
Thanks
(sp is a stored procedure with one numeric parameter)
declare @sql as nvarchar(200)
declare @tablevar table
(a Char(10),
b int,
c Numeric(5,2),
d Numeric(5,2))
set @sql = 'insert into '+ @tablevar + ' exec sp 2002'
exec sp_executesql @sql
I pretty sure a table variable is not available in the dynamic sql. Any other idea's on how to get the results of a sp inserted into a table variable?
Thanks