SET XACT_ABORT on ----设置 gocreate table #Table1 (a tinyint) go begin tran insert #table1 values(1) ----成功 insert #table1 values(1000) ----这句将报错 commit tran go select * from #table1 go drop table #table1
create table Table1 (a int) go begin tran insert table1 values(1) ----这句是对的 insert table1 values('aaa') ----这句由于类型不一样将报错 commit transelect * from table1 ------结果是两句都没插入!应为他们是一个事务
gocreate table #Table1 (a tinyint)
go
begin tran
insert #table1 values(1) ----成功
insert #table1 values(1000) ----这句将报错
commit tran
go
select * from #table1
go
drop table #table1
go
begin tran
insert table1 values(1) ----这句是对的
insert table1 values('aaa') ----这句由于类型不一样将报错
commit transelect * from table1 ------结果是两句都没插入!应为他们是一个事务