update table2
set [money]=table2.[money]+table1.[money]
from table1
where table2.name=table1.nameinsert table2(name,[money])
select name,[money] from table1
where not exists (
select 1 from table2
where table2.name=table1.name
)
set [money]=table2.[money]+table1.[money]
from table1
where table2.name=table1.nameinsert table2(name,[money])
select name,[money] from table1
where not exists (
select 1 from table2
where table2.name=table1.name
)
如果不需要修改table2,而是只要select加总的结果select name,sum([money]) as [money]
from (
select * from table1
union all
select * from table2
) as x
group by name
insert table2 select * from table1 where name not in(select name from table2)