用游标可以,但是没必要啊,连存储过程也没必要,直接一个update加一个insert就可以了呀。
update B set b.col=a.col from A where b.aa=a.aa and b.bb=a.bbinsert into B select * from A where not exists (select 1 from B where b.aa=a.aa and b.bb=a.bb )