1

I came to know we can go for roll back transaction using "set xact_abort on" i want to know which is the better way for roll back transaction: use "set xact_abort on" or simple the following code

begin try
begin tran
-- statements 
commit tran
end try
begin catch
rollback tran
end catch

Please help me to choose which is better approach while inserting number of records one time.

Ram Singh
  • 6,664
  • 35
  • 100
  • 166

1 Answers1

0

The code you mentioned is what I normally follow since it allows handling error conditions in a graceful manner. You can log extra information like source/proc params used etc in catch block when used in a proc.

2lazydba
  • 398
  • 3
  • 10