begin tran
insert into a values(1,11,111)
if @@error <> 0 then goto Err
insert into a values(2,11,111)
if @@error <> 0 then goto Err
insert into a values(3,11,111)
if @@error <> 0 then goto Err
insert into a values(4,18,111)
if @@error <> 0 then goto Err
insert into a values(7,81,111)
if @@error <> 0 then goto Err
commit
return
Err:
rollback
insert into a values(1,11,111)
if @@error <> 0 then goto Err
insert into a values(2,11,111)
if @@error <> 0 then goto Err
insert into a values(3,11,111)
if @@error <> 0 then goto Err
insert into a values(4,18,111)
if @@error <> 0 then goto Err
insert into a values(7,81,111)
if @@error <> 0 then goto Err
commit
return
Err:
rollback
SET NOCOUNT ON
SET XACT_ABORT ON
create table a(
i tinyint,
ii smallint,
iii int
)
insert into a values(1,11,111)
insert into a values(2,11,111)
insert into a values(3,11,111)
insert into a values(4,18,111)
insert into a values(7,81,111)
commit transaction
中间放程序
conntemp.CommitTrans
as
begin transaction
create table a(
i tinyint,
ii smallint,
iii int
)
if @@error<>0
rollback
insert into a values(1,11,111)
if @@error<>0
rollback
insert into a values(2,11,111)
if @@error<>0
rollback
insert into a values(3,11,111)
if @@error<>0
rollback
insert into a values(4,18,111)
if @@error<>0
rollback
insert into a values(7,81,111)
if @@error<>0
rollback
commit transaction
这样对吗
insert into a values(1,11,111)
insert into a values(2,11,111)
insert into a values(3,11,111)
insert into a values(4,18,111)
insert into a values(7,81,111)
commit tran
insert into a values(1,11,111)
insert into a values(2,11,111)
insert into a values(3,11,111)
insert into a values(4,18,111)
insert into a values(7,81,111)
commit tran