Last active
August 29, 2015 14:27
-
-
Save tompazourek/8d650ee6dadfb5fbc780 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 | |
-- statements here | |
COMMIT TRAN | |
END TRY | |
BEGIN CATCH | |
IF @@TRANCOUNT > 0 | |
ROLLBACK TRAN | |
PRINT 'Actual error number: ' + CAST(ERROR_NUMBER() AS VARCHAR(10)); | |
PRINT 'Actual line number: ' + CAST(ERROR_LINE() AS VARCHAR(10)); | |
DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE(); | |
DECLARE @ErrorSeverity INT = ERROR_SEVERITY(); | |
DECLARE @ErrorState INT = ERROR_STATE(); | |
RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState); | |
END CATCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment