Skip to content

Instantly share code, notes, and snippets.

@ryanande
Created May 7, 2019 20:53
Show Gist options
  • Save ryanande/6ed97e42676cfbeb4f68a4458b7e3242 to your computer and use it in GitHub Desktop.
Save ryanande/6ed97e42676cfbeb4f68a4458b7e3242 to your computer and use it in GitHub Desktop.
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