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

This code adds the message in "Sys.messages" of sql server.
sp_addmessage 50006 , 18 , 'error occurred while updating the variable value',
@with_log = 'true',
@Replace='replace'

But i want the same message to be logged in system event log also.But this code doesnot add the message to event log.Can anyone tell me what is the problem with the code?
Posted

1 solution

If you want to write to the Windows Event log, use xp_logEvent

http://msdn.microsoft.com/en-us/library/aa260695%28SQL.80%29.aspx[^]
 
Share this answer
 
Comments
froxy 3-Feb-11 5:41am    
I executed the following code.But the message was not available in Event viewer.

USE master
EXEC xp_logevent 60006,'fsdfsdf', informational

Where can i look for the message?
Dylan Morley 3-Feb-11 5:54am    
It will show under the Application log, with a source of MSSQLSERVER

Can you confirm you have the correct permissions?

"Requires membership in the db_owner fixed database role in the master database, or membership in the sysadmin fixed server role."

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