When SQL Server encounters a problem, it writes a message from the sysmessages system table to the error log or sends it to the client, depending on the severity level.
Each message contains:
For example, if you try to access a table that doesn't exist:
select * from bogus
The error message sent to the client looks something like this:
Msg 208, Level 16, State 1 Invalid object name 'bogus'.
You can see a list of SQL Server error messages by selecting data from the sysmessages table in the master database. For a complete list of the messages in sysmessages, see Chapter 26, "System Messages."