Firstly is there any error trapping in the proc, if not add some like this
This should folow every bit of code
SELECT
@Error = @@ERROR
,@NumRows = @@ROWCOUNT
,@ErrorMsg = 'Enter appropriate message'
IF @Error > 0 GOTO Error
then add this at the bottom of the proc
Error: -- Errors have been detected, continue and exit cleanly
SET NOCOUNT OFF
RAISERROR ('Proc Failed: %s Error Message: %s ErrorNo: %d Num of rows: %d',16,1,'ProcName',@ErrorMsg,@Error,@NumRows)
RETURN 1 -- exit returning status value of 1 (to indicate failure)
GO
For eg... If I insert a Duplicate entry which is a primary key column
SQL gives Primary Key Violation Error
with error line number etc... It takes the values from system.dbo.sysmessages
I want the same message to appear when the error occurs
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.