在sql server 2008中根据表A来更新表B中数据的方法,分享几个例子,大家参考下。
1,多个字段更新
update p set p.CityArea=p1.CityArea, p.Spell=p1.Spell, p.Abbr=p1.Abbr, p.Sort=p1.Sort from Area p , Areabak20120718 p1 where p.ID =p1.ID
2.单个字段更新
Update productDetail set Mtitle = (select [name] from product where id = productDetail.productid )
3.根据表2删除表1
delete Product_@i from Dealers d where d.dealerid= Product_@i.dealerid and d.LastLoginTime <''2012-07-01 00:00:00'' ;