2

I am working with sql server 2012 and have some jobs set up on it to run at different times during the day. If the job fails I want to be alerted of such.

On the server I have some software the monitors the event viewer. I would like to set up my jobs to write to the servers event viewer if the job fails. I would like to write with event id 999 and level of error.

How can I set up my jobs to do so?

amateur
  • 43,371
  • 65
  • 192
  • 320

1 Answers1

4

You can use SQL-command xp_logevent

EXEC master.dbo.xp_logevent 60000, 'Test message', informational

but it does not allow you set "event id", you can set only "error number"

Or you can create "power shell" job step with something like:

write-eventlog System -source Server -eventid 12345 -message "I am a custom event log message"

and enter the job step only on failure action in prev step

Alexander Sigachov
  • 1,541
  • 11
  • 16