Alters the state of a sysmessages error.
sp_altermessage message_id, WITH_LOG, {true | false}
where
Note If a message is written to the Windows NT event log, it is also written to the SQL Server error log file.
The effect of the sp_altermessage system stored procedure with the WITH_LOG option is similar to that of the RAISERROR WITH LOG parameter, except that sp_altermessage changes the logging behavior of an existing message. If a message has been altered to be WITH_LOG, then no matter how a user invokes the error it will always be written to the Windows NT event log. Even if RAISERROR is executed without the WITH LOG option, the error will be written to the Windows NT event log.
System messages (such as 605), as well as user messages added by sp_addmessage, can be modified by using sp_altermessage.
This example causes existing message 55001 to be logged to the Windows NT event log.
sp_altermessage 55001, WITH_LOG, TRUE
Execute permission defaults to the system administrator and can be transferred to other users.
sysmessages
sp_addmessage | sp_dropmessage |