Home > SQL Server > SQL SERVER – Writing Message to Windows Event and SQL Server Log

SQL SERVER – Writing Message to Windows Event and SQL Server Log


xp_logevent :  This system stored procedure is used to send the user defined log data to SQL Server log and Windows Even log at the same time. But, this stored procedure does not send the log data to the client.

Usage

xp_logevent  error_number , ‘message’  , ‘severity’

error_number : This is the use defined error number starts from 50,000 to 2147483647. The error numbers from 1 to 49999 is assigned to system messages. system error messages can be obtained from sys.messages and sys.sysmessages.

message : This is the user defined message string of maximum length 2048 characters.

severity : This is an optional character string INFORMATIONAL, WARNING, or ERROR. The default value is INFORMATIONAL.

Example

1. This is the simple example to show how to invoke the stored procedure with user defined log message.

exec xp_logevent 50001, ‘From SQL Server Rider’

pic1Output

pic2

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: