Insert into table from table variable?

DECLARE @t TABLE
(
ID uniqueidentifier,
ID2 uniqueidentifier
)

      

... insert into @t ... make stuff for @t

INSERT INTO testTable (Id, Id2) VALUES (SELECT ID, ID2 from @t)

- does not work?

+3


source to share


2 answers


Here's how you should do it:



INSERT INTO testTable (Id, Id2)
SELECT ID, ID2 
from @t

      

+5


source


How about this?



INSERT INTO testTable SELECT ID, ID2 from @t

      

0


source







All Articles