sqlserver merge into

create table #ttt(id int,name nvarchar(10));
merge into #ttt t
using (select 1 as id ,'eee' as name ) b
on (t.id = b.id)
when matched then
update set t.name = b.name
when not matched then
insert(id,name) values(b.id,b.name);



select * from #ttt;




merge into  a
using  b
on (a.id = b.id)
when matched then
update set a.name = b.name
when not matched then
insert(id,name) values(b.id,b.name);


select * from a;
posted @ 2015-12-23 15:37  甜菜波波  阅读(1415)  评论(0编辑  收藏  举报