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.

1_sql server error message table

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.

The procedure adds a custom message “This is a custom error message” with message_id 51000 and severity level 16 to sys.messages view.

2_sql server error message table

The custom message is added to the sys.messages table as shown in above snapshot.



Ahmad Osama

Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook