Friday, February 27, 2015

Raiserror behavior in TRY-CATCH block

I also want to add to Erland above answer, that if you do not want to "SET XACT_ABORT ON" you can use the following format, to have the same result of rolling back al transactions.



BEGIN TRY
BEGIN TRAN
SELECT 1/0 (example tran)
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
THROW
END CATCH

This way you will have your Error Handeling in place.


Regards,


Reshma




Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered


No comments:

Post a Comment