34,593
社区成员
发帖
与我相关
我的任务
分享
if object_id('表a') is not null
drop table 表a
go
if object_id('表b') is not null
drop table 表b
go
create table 表a(name varchar(20) not null)
create table 表b(name varchar(20))
begin try
begin tran
insert into 表a select null
insert into 表b select 'c'
commit tran
end try
begin catch
rollback
end catch
--全部回滚
set xact_abort on
begin try
begin tran
insert into 表a select 'a'
insert into 表b select 'c'
select * from oooo --高级别错误 设置xact_abort,否则不会回滚
commit tran
end try
begin catch
rollback
end catch
select * from 表a
select * from 表b