SQL Server Performance Forum – Threads Archive
Registering error codes with sp_addmessageA couple of quick questions: 1)If I have a SQL script defining several procedures, may sp_addmessage be called in this script outside any procedure, or does it work on a per-procedure basis? 2)When do messages registered get removed? And are they global or local – can say 50001 be registered in two different places against different message text?
1. yes it may be called outside any SP 2. messages get removed when sp_dropmessage is run. They are global (on a server) – you may only have one 50001 message on the server. You need to manage them to ensure you don’t try to add 2 different messages with the same ID.