Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert into table from table variable?

DECLARE @t TABLE
(
ID uniqueidentifier,
ID2 uniqueidentifier
)

...insert into @t ...do stuff to @t

INSERT INTO testTable (Id, Id2) VALUES (SELECT ID, ID2 from @t) -does not work?

like image 389
Shawn Avatar asked Feb 18 '23 14:02

Shawn


1 Answers

This is how you should do that:

INSERT INTO testTable (Id, Id2)
SELECT ID, ID2 
from @t
like image 66
gzaxx Avatar answered Feb 20 '23 04:02

gzaxx