begin tran set nocount on if IF @@ERROR <> 0 goto QuitWithRollback .... if IF @@ERROR <> 0 goto QuitWithRollback ... if IF @@ERROR <> 0 goto QuitWithRollback commit transaction GOTO EndSave QuitWithRollback: IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION EndSave: set nocount off
begin TRANSACTION set nocount on if IF @@ERROR <> 0 goto QuitWithRollback .... if IF @@ERROR <> 0 goto QuitWithRollback ... if IF @@ERROR <> 0 goto QuitWithRollback commit transaction GOTO EndSave QuitWithRollback: IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION EndSave: set nocount off
commit work的对应关系是否一致。
要:begin tran ..commit tran
set nocount on
if IF @@ERROR <> 0 goto QuitWithRollback
....
if IF @@ERROR <> 0 goto QuitWithRollback
... if IF @@ERROR <> 0 goto QuitWithRollback
commit transaction
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
set nocount off
set nocount on
if IF @@ERROR <> 0 goto QuitWithRollback
....
if IF @@ERROR <> 0 goto QuitWithRollback
... if IF @@ERROR <> 0 goto QuitWithRollback
commit transaction
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
set nocount off