码迷,mamicode.com
首页 > 数据库 > 详细

sqlserver merge into

时间:2015-12-23 16:03:42      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

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;

sqlserver merge into

标签:

原文地址:http://www.cnblogs.com/tiancai/p/5070109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!