I'm having an issue on settin up
On my Stored Proc i'm raising an error
--@number = 50001 RAISERROR(@number, 16, 1) -
I should expect that the
Error_Number() should be
@number but I always get 18054
Is there something wrong with my
Check the sys.messages table for error code 74601. if this is a user defined error, it shouold be added in the table.
for any error that is greater than 50000 should give you this output if not found.
Msg 18054, Level 16, State 1, Line 1 Error XXXXX, severity 16, state 1 was raised, but no message with that error number was found in sys.messages. If error is larger than 50000, make sure the user-defined message is added using sp_addmessage.Answer2:
There is one small caveat: You can't supply a message on your own in this case. But this can be circumvented by adding an additional %s in the sp_addmessage call or by changing all mapped messages to your own pattern and supplying the right parameters in the raiseerror call.
Check there for more information: <a href="https://stackoverflow.com/questions/1882788/sql-server-rethrow-exception-with-the-original-exception-number" rel="nofollow">SQL Server: Rethrow exception with the original exception number</a><blockquote>
RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically.</blockquote>
Check for your error message exists or not using this:
select * from sys.messages
If it does not exists then Use
sp_addmessage to add user-defined error messages and
sp_dropmessage to delete user-defined error messages.
for more information follow <a href="http://msdn.microsoft.com/en-us/library/ms178592.aspx" rel="nofollow">RaiseError</a> documentation.