insert into a表 select * from aa表 where ..... --将aa表中满足一定条件的数据插入到a表,两个表的表结构完全相同。(下同)
update a表 set XXX from aa表 where .....insert into b表 select * from bb表 where .....
update b表 set XXX from bb表 where ........
...
aa表,bb表,cc表.....共有10多个表,每个表都有20多万条记录。我现在想要做的事是:将上面对10多个表的所有操作放在同一个事务里(因为这些表之间都有一定关联的),为了保证数据的完整性,应该如何做?这么大的数据量能实现么?谢谢大家了
update a表 set XXX from aa表 where .....insert into b表 select * from bb表 where .....
update b表 set XXX from bb表 where ........
...
aa表,bb表,cc表.....共有10多个表,每个表都有20多万条记录。我现在想要做的事是:将上面对10多个表的所有操作放在同一个事务里(因为这些表之间都有一定关联的),为了保证数据的完整性,应该如何做?这么大的数据量能实现么?谢谢大家了
看不懂
-------
begin tran
insert into a表 select * from aa表 where ..... --将aa表中满足一定条件的数据插入到a表,两个表
insert into b表 select * from bb表 where .....
.
.
.
if @@error=0
commit tran
else
rollback tran
set xact_abort onbegin tran--你的批处理SQL语句commit tran