Alters the state of a sysmessages error.
sp_altermessage [@message_id =] message_number,
[@parameter =] 'write_to_log',
[@parameter_value =] 'value'
Note If a message is written to the Windows NT application log, it is also written to the Microsoft SQL Server™ error log file.
0 (success) or 1 (failure)
None
The effect of sp_altermessage 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, it is always written to the Windows NT application log, regardless of how a user invokes the error. Even if RAISERROR is executed without the WITH LOG option, the error is written to the Windows NT application log.
System messages (such as 605), as well as user messages added by sp_addmessage, can be modified by using sp_altermessage.
Only members of the sysadmin fixed server role can execute sp_altermessage.
This example causes existing message 55001 to be logged to the Windows NT application log.
sp_altermessage 55001, 'WITH_LOG', 'true'
sp_addmessage | System Stored Procedures |
sp_dropmessage |