Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to write to a sql error to windows server event viewer

18 April,2017 by Tom Collins

Over the last few versions SQL Server has improved greatly on writing sql server  error messages . A good example is writing  to both SQL Server Error Log and the windows server event viewer.

There are a number of benefits in writing a SQL Server error to the windows event viewer.

  1. Centralising error messages to the one source makes it more efficient for a monitoring application. It is possible for the monitoing package to parse the Windows event viewer and extract all alerting situations from the one source. This minimises the access footprint on the server . There is no requirement for the monitoring applications to log into SQL Server.
  2. The DBA may want to manage alert messaging to different groups of administrators. For example , windows \ OS bases alerts could go to Windows Event Viewer and SQL Server Errors to the SQL Server Logs.


To write a message to windows event viewer is impolemented by using the procedure : xp_logevent

An example is :


EXEC xp_logevent 60000, 'A message from MSSQL$TEST', informational


Which would generate an Windows Event Viewer entry in the Application Logs

Error: 60000 Severity: 10 State: 1 A message from MSSQL$TEST


Note: db_owner or sysadmin is required


Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to write to a sql error to windows server event viewer | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer