Reputation: 51
I want to know if it is possible to insert to a table from a specific column of result from a stored procedure?
Something like:
declare @temp as table(
id int
)
insert @temp
exec getlistofStudents --returns multiple columns
this is an example only, Thanks for the help..
Upvotes: 0
Views: 3292
Reputation: 5367
You can take a 2 step approach. First INSERT INTO a #TempTable, then populate the @TempVariable with another INSERT INTO, selecting the single column.
DECLARE @temp AS TABLE
(
ID int
);
CREATE TABLE #tempTable1
(
Column1 int,
Column2 int
);
INSERT INTO #tempTable1
Exec getlistofStudents
INSERT INTO @temp
SELECT Column1 FROM #tempTable1
Upvotes: 1