插入到表从表变量?(Insert into table from table variable?)

2019-08-16 20:52发布

DECLARE @t TABLE
(
ID uniqueidentifier,
ID2 uniqueidentifier
)

...插入@t ...做的东西@t

INSERT INTO testTable (Id, Id2) VALUES (SELECT ID, ID2 from @t) -不工作?

Answer 1:

这是你应该怎么做:

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


Answer 2:

这个怎么样?

INSERT INTO testTable SELECT ID, ID2 from @t


文章来源: Insert into table from table variable?