Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize


SQL Server 2000

Logs a user-defined message in the Microsoft® SQL Server™ log file and in the Microsoft Windows NT® Event Viewer. xp_logevent can be used to send an alert without sending a message to the client.


xp_logevent {error_number, 'message'} [, 'severity']



Is a user-defined error number greater than 50,000. The maximum value is 1073741823 (230 - 1).


Is a character string with a maximum of 255 characters.


Is one of three character strings: INFORMATIONAL, WARNING, or ERROR. severity is optional, with a default of INFORMATIONAL.

Return Code Values

0 (success) or 1 (failure)

Result Sets

xp_logevent returns this error message for the included code example:

The command(s) completed successfully.

When sending messages from Transact-SQL procedures, triggers, batches, and so on, use the RAISERROR statement instead of xp_logevent. xp_logevent does not call a client's message handler or set @@ERROR. To write messages to the Windows NT Event Viewer and to the SQL Server error log file within SQL Server, execute the RAISERROR statement.


Execute permissions for xp_logevent default to members of the db_owner fixed database role in the master database and members of the sysadmin fixed server role, but can be granted to other users.


This example logs the message (with variables passed to the message) in the Windows NT Event Viewer.

DECLARE @@TABNAME varchar(30)
DECLARE @@USERNAME varchar(30)
DECLARE @@MESSAGE varchar(255)
SET @@TABNAME = 'customers'
SELECT @@MESSAGE = 'The table ' + @@TABNAME + ' is not owned by the user 
   ' + @@USERNAME + '.'

USE master
EXEC xp_logevent 60000, @@MESSAGE, informational

See Also



System Stored Procedures (General Extended Procedures)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft