Create Procedure XXX
Set nocount on
--Declaration Section
Begin Transaction Trans1
Commit Transaction Trans1
End Try
Begin Catch
Declare
@ErrorMessage NVARCHAR(4000),
-- Assign variables to error-handling functions that it capture
information for RAISERROR.
Select
@ErrorNumber =
ERROR_NUMBER(),
-- Building the message string that will contain original error
information.
Select
@ErrorMessage =
N'Error %d, Level %d, State
%d, Procedure %s, Line %d, Message: '+ ERROR_MESSAGE();
If XACT_STATE() <> 0 Rollback Transaction Trans1
-- Raise an error: msg_str parameter of RAISERROR will contain the
original error information.
Raiserror
END
No comments:
Post a Comment