- A TRY Block - the TRY block contains the code / script that might cause an exception
- A CATCH Block - if an exception occurs from one of the statements in the TRY block, control is branched to the CATCH block, where the exception can be handled, logged, and so on.
BEGIN TRY
BEGIN TRANSACTION
stmts...
END TRAN
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRAN
END CATCH
1 comment:
I found your post helpful while trying to figure this out. I added a couple of statements in my CODE to show the program flow.
Thanks,
Post a Comment