Return to Snippet

Revision: 52508
at October 25, 2011 11:11 by amos24c


Updated Code
BEGIN TRY
BEGIN TRAN


COMMIT TRAN
END TRY

BEGIN CATCH
  Declare @ErrorMessage varchar(2000) = (select ERROR_MESSAGE())
  Declare @ErrorSeverity int = (select ERROR_SEVERITY())
  Declare @ErrorState int = (select ERROR_STATE())
  ROLLBACK TRANSATION
  RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState)

END CATCH

Revision: 52507
at October 25, 2011 11:10 by amos24c


Initial Code
BEGIN TRAN
BEGIN TRY

COMMIT TRAN
END TRY

BEGIN CATCH
  Declare @ErrorMessage varchar(2000) = (select ERROR_MESSAGE())
  Declare @ErrorSeverity int = (select ERROR_SEVERITY())
  Declare @ErrorState int = (select ERROR_STATE())
  ROLLBACK TRANSATION
  RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState)

END CATCH

Initial URL

                                

Initial Description
Boiler Plate for T-Sql Error handling

Initial Title
T-SQL Error Handling

Initial Tags
error

Initial Language
SQL