Contact Us

Use the form on the right to contact us.

You can edit the text in this area, and change where the contact form on the right submits to, by entering edit mode using the modes on the bottom right. 


Oak Ridge, TN, 37830
United States

Sql-Sangria

Transaction Try Catch Template

Wade Cantley

Try/Catch Margarita

2 oz Agave Nector
3 oz Lime Juice
Salt, course
2 1/2 oz Curacao Liqueur, blue
5 oz Silver Tequila

BEGIN TRANSACTION

BEGIN TRY
    -- Generate a constraint violation error.
    DECLARE @var INT
    SET @var = 'bob'

END TRY
BEGIN CATCH
    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

    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION
END CATCH;

IF @@TRANCOUNT > 0
    COMMIT TRANSACTION
GO