Click here to Skip to main content
15,888,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All

SQL
sp_addmessage 50006 , 18 , 'error occurred while updating the variable value',  
@with_log = 'true',
@Replace='replace'

select * from sys.messages


This code adds the message only in sys.messages. But i want the code to add the message in event log also.Can anyone help me.
Posted
Updated 2-Feb-11 23:38pm
v2

1 solution

Try without @replace or check the return code [0 (success) or 1 (failure)]

[ @replace = ] 'replace'
If specified as the string replace, an existing error message is overwritten with new message text and severity level. replace is varchar(7) with a default of NULL. This option must be specified if msg_id already exists. If you replace a U.S. English message, the severity level is replaced for all messages in all other languages that have the same msg_id.


I found on MSDN that it requires membership in the sysadmin and serveradmin fixed server roles. (In case that may be the case)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900