34,593
社区成员
发帖
与我相关
我的任务
分享
-- 使用 merge ,values 的部分, 可以直接拿出来,取个别名就可以了
create table test(a int, b int)
go
insert into test values(101,200),(200,300)
go
merge into test using
(
values
(100,200),
(200,300),
(300,400),
(222,333)
) t(a,b) -- 这个是别名
on test.a = t.a and test.b = t.b
when not matched then
insert (a,b) values(t.a,t.b);
go
select * from test
go
drop table test
go
(2 行受影响)
(3 行受影响)
a b
----------- -----------
101 200
200 300
100 200
300 400
222 333
(5 行受影响)