none
What is the most effective way to write Statement to catch and reverse errors during query excution? RRS feed

  • Question

  • Hello my friends:

    I am wondering what is the most effective way to deal with errors, specifically in a Stored Procedure.

    I wrote something like this:

    BEGIN TRY
    BEGIN TRANSACTION
    
    /*My statements goes in here*/
    
    IF ERROR_NUMBER() = 0 -- Do I need this line?
    
    COMMIT TRANSACTION;
    
    END TRY
    
    BEGIN CATCH
    
    IF ERROR_NUMBER() > 0 --Do I need this line?
    
    ROLLBACK TRANSACTION;
    
    END CATCH;


    It would make sense using the if Statement when attempting to log errors.

    Just too many variations.

    Thanks

    Thursday, September 11, 2014 3:56 AM

Answers

All replies