How to write errorlog to the SQL errorlog file from stored proc

Suppose i am executing a stored proc . Lets there is an exception, how do i write the log in errorlog of MSSQL?

I read about RAISERROR, i got to know that it basically throw exception message to the batch or application? can someone provide me some links to read about it. Suppose if the stored procedure returns int after executing , will it still return the value in case raiserror is called?

more ▼

asked Mar 20, 2013 at 11:58 AM in Default

avatar image

470 14 14 19

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You can just specify LOG as part of the RAISERROR command. You can see the details in the Books Online.

For more detail around how to deal with errors in SQL Server, I have an older article that works all around errors and error handling. It was written for SQL Server 2005, but it's still mostly applicable to 2008R2 and 2012.

more ▼

answered Mar 20, 2013 at 12:06 PM

avatar image

Grant Fritchey ♦♦
137k 20 46 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Mar 20, 2013 at 11:58 AM

Seen: 1576 times

Last Updated: Mar 20, 2013 at 12:06 PM

Copyright 2018 Redgate Software. Privacy Policy