In previous versions we raised errors in t-sql like:
RAISERROR 50000 'My Error Message'
In the latest SQL Server this syntax has been discontinued and replace with the RaiseError () syntax.
I would like to have a generic method of raising errors, and the best I could come up so far is:
sp_addmessage @msgnum = 50001,
@severity = 10,
@msgtext = N'My Error Message', @replace = 'REPLACE';
RAISERROR (50001, 10, 1, 'This error message is not displayed')
But I can't go and create a error message with sp_addmessage for every message, because there are 1000's.
What is the better way to raise messages with a custom message?