Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Is it posibble to specify a custom error number associated with RAISERROR statement. By default, SQL SERVER 2008 is assigning "50000".Issue: Based on the error number returned from Database, custom implementation has to be done in Front End coding. Currently, all errors raised through RAISERROR statement provides "50000" as Error Number(with error messages specific to an error).
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2009-09-08 : 08:16:09
You can possibly use sp_addmessage to do this, but you would need to provide an error message as well:
Thanks. I have another question.Suppose RAISERROR is called in a CATCH Block to re-throw an error, is it possible to set the error number (instead of 50000 or custom one) with SQL SERVER generated error number. So the error message alone will be a customized one but ERROR NUMBER remains the same(not custom error number).
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2009-09-09 : 05:27:47
You should get the original error number anyway.Set a variable to ERROR_NUMBER() and use that in your RAISERROR call.So: