SQl Server error handling pattern

Posted by Patrick Honorez on Stack Overflow See other posts from Stack Overflow or by Patrick Honorez
Published on 2010-05-19T10:36:29Z Indexed on 2010/05/19 10:40 UTC
Read the original article Hit count: 195

Filed under:
|
|

Hi all. I am not an expert on SQl Server. Is this a valid pattern for handling errors in a batch of SELECT, INSERT...in SQl SERVER ? (I use v.2008)

BEGIN TRANSACTION
    BEGIN TRY
       -- statement 1
       -- statement 2
       -- statement 3
       COMMIT TRANSACTION
    END TRY

    BEGIN CATCH
       ROLLBACK TRANSACTION
    END CATCH

Thanks

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server