a表
id name age
1 wang 18
2 zhang 19
3 su 20
b表
id name age
1 wang 20
2 zhang 21
3 su 22
两个表的字段完全相同
现在我需要把B表中ID为1的数据,更新到对应a表中去,如果要更新字段比较多的,求最简便的SQL语句
------解决方案--------------------
delete from a where id = 1;
insert into a select * from b where b.id = 1;
------解决方案--------------------
SQL2K8以上
DELETE FROM A
OUTPUT DELETED.id,DELETED.name,DELETED.age
INTO B(id,name,age)
WHERE id =1