Monday, 26 March 2012

RAISERROR with Log

DECLARE @ERROR_NUMBER INT

DECLARE @ERROR_SEVERITY INT

DECLARE @ERROR_STATE INT

DECLARE @ERROR_PROCEDURE NVARCHAR(252)

DECLARE @ERROR_LINE INT

DECLARE @ERROR_MESSAGE NVARCHAR(4000)

SELECT @ERROR_NUMBER = ERROR_NUMBER() , @ERROR_NUMBER = ERROR_NUMBER() , @ERROR_SEVERITY = ERROR_SEVERITY() , @ERROR_STATE = ERROR_STATE() , @ERROR_PROCEDURE = ERROR_PROCEDURE() , @ERROR_LINE = ERROR_LINE() , @ERROR_MESSAGE = ERROR_MESSAGE()

EXEC CPV.uspInsertSQLErrorLog @ERROR_NUMBER , @ERROR_SEVERITY , @ERROR_STATE , @ERROR_PROCEDURE , @ERROR_LINE , @ERROR_MESSAGE

RAISERROR(@ERROR_MESSAGE,@ERROR_SEVERITY,@ERROR_STATE) /******Raise Error backto client *****/

No comments:

Post a Comment