SQL Server error message table or catalog view has the error messages which are being displayed by SQL Server when an error occurs. The error message catalog views are sys.sysmessages and sys.messages and the get there values from master.sys.sysusermsgs table. Let’s analyze the content of sys.messages catalog view.
The severity level tells the type of the problem. To understand what each of the severity level refer to http://msdn.microsoft.com/en-us/library/aa937483(SQL.80).aspx.
A user can add customized error messages with in severity level 1-25 using sp_addmessage stored procedure. The below query adds a custom message to sys.messages catalog view.
USE master; GO EXEC sp_addmessage 51000, 16, N'This is a custom error message'
The procedure adds a custom message “This is a custom error message” with message_id 51000 and severity level 16 to sys.messages view.
The custom message is added to the sys.messages table as shown in above snapshot.
Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook