如果是SQL2008 用MERGE 关键字
详细:http://www.cnblogs.com/andy_tigger/archive/2012/01/11/2319780.html
如果是SQL2005 以下版本
必须两个语句:
update + insert
例如:update A set Name = b.name
from A a inner join B b where a.id = b.idinsert into A
select * from B b where not exists(select 1 from A a where a.id = b.id)
详细:http://www.cnblogs.com/andy_tigger/archive/2012/01/11/2319780.html
如果是SQL2005 以下版本
必须两个语句:
update + insert
例如:update A set Name = b.name
from A a inner join B b where a.id = b.idinsert into A
select * from B b where not exists(select 1 from A a where a.id = b.id)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货