Use sp_addmessage to write to EventLog with a different event id

I have a set of custom messages in SQL Server that I write to the event log, and I never realized that they all write with the same EVENTID 17063 in the application event log, how can I specify sp_addmessage to write a custom EvenID so that everyone is not registered with EVENTID 17063?

EXEC sp_addmessage @msgnum = 90002, @severity = 16, @msgtext = N'some text ', @lang =' us_english ', @with_log =' TRUE ', @replace =' replace '; ReplyQuote

+4
source share
1 answer

I believe that EVENTID 17063 indicates that the event source is SQL Server, so you cannot change it using the sp_addMessage stored procedure.

However, if you can use the CLR, you can create a wrapper around the EventLog.WriteEntry method, which allows you to change the EVENTID.

http://msdn.microsoft.com/en-us/library/f6wy11we.aspx

0
source

Source: https://habr.com/ru/post/1344183/


All Articles