Log T-SQL Error in Application Log and Error Log using RAISERROR.

RAISERROR (13043, — Message id.
           0, — Severity,
           0, — State,
           N’audit’) WITH LOG;

Here 13043 will send the string and will not identify anything written as the last parameter. In the above example the last parameter is N’audit’. Also WITH LOG confirms that the error is logged in the Applicatin Log and error log both.

INTERVIEW PREPARATION IN 30 MINs – Read Following wires for a quick interview preparation.

  1. SQL Server DBA “Interview Questions And Answers”
  2. SQL Azure Interview Questions and Answers Part – 1
  3. SQL Azure Interview Questions and Answers Part – 2
  4. Powershell Interview Questions and Answers

The good thing about this is that you also get the spid in the error log from where the error is thrown. The RAISERROR can be used in try catch to throw specific errors. The new errors can be added in the sys.sysmessages using sp_addmessage. Write me if you want to learn about this.

Regards,
Online MSSQL Classes @ http://tuitionaffordable.webstarts.com

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s