Created
May 7, 2019 20:53
-
-
Save ryanande/6ed97e42676cfbeb4f68a4458b7e3242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRY | |
BEGIN TRANSACTION MEDELETE | |
DELETE FROM -- | |
COMMIT TRANSACTION MEDELETE | |
END TRY | |
BEGIN CATCH | |
IF (@@TRANCOUNT > 0) | |
BEGIN | |
ROLLBACK TRANSACTION MEDELETE | |
PRINT 'Error detected, all changes reversed' | |
END | |
SELECT | |
ERROR_NUMBER() AS ErrorNumber, | |
ERROR_SEVERITY() AS ErrorSeverity, | |
ERROR_STATE() AS ErrorState, | |
ERROR_PROCEDURE() AS ErrorProcedure, | |
ERROR_LINE() AS ErrorLine, | |
ERROR_MESSAGE() AS ErrorMessage | |
END CATCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment