BEGIN TRANSACTION
BEGIN TRY
-- YOUR SQL
COMMIT
END TRY
BEGIN CATCH
ROLLBACK
END CATCH
The above code is executed in SQL SERVER 2008.
After using TRY CATCH, will run as long as the abnormal CATCH inside rolled back. I like the code clearer familiar C # exception handling.
Reproduced in: https: //www.cnblogs.com/orangepoet/archive/2011/11/15/2250054.html