首页 > 数据库技术 > 详细

sqlserver merge into

时间:2015-12-23 16:01:30      阅读:262      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!