<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Error Handling in T-SQL</title>
	<atom:link href="http://sqlfool.com/2008/12/error-handling-in-t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/</link>
	<description>Adventures in SQL Tuning - a blog for the rest of us</description>
	<lastBuildDate>Thu, 04 Feb 2010 08:21:02 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Monitoring Process for Performance Counters : SQL Fool</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-4938</link>
		<dc:creator>Monitoring Process for Performance Counters : SQL Fool</dc:creator>
		<pubDate>Wed, 16 Sep 2009 17:22:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-4938</guid>
		<description>[...] Getting an error about dba_logError_sp? Take a look at my error handling proc. [...]</description>
		<content:encoded><![CDATA[<p>[...] Getting an error about dba_logError_sp? Take a look at my error handling proc. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-01-08 &#171; News to Me</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-126</link>
		<dc:creator>links for 2009-01-08 &#171; News to Me</dc:creator>
		<pubDate>Thu, 08 Jan 2009 15:01:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-126</guid>
		<description>[...] Error Handling in T-SQL (tags: sql howto sqlserver error) [...]</description>
		<content:encoded><![CDATA[<p>[...] Error Handling in T-SQL (tags: sql howto sqlserver error) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michelle Ufford</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-84</link>
		<dc:creator>Michelle Ufford</dc:creator>
		<pubDate>Sun, 21 Dec 2008 14:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-84</guid>
		<description>Hi Jamie,

The error proc, dba_logError_sp , will indeed return the error to the calling app if @returnError = 1, which is the default behavior.  

    /* Should we return an error message to the calling proc? */
    IF @returnError = 1
        RAISERROR
        (
              @errorReturnMessage
            , @errorReturnSeverity
            , 1
        ) WITH NOWAIT;

The reason I wrote the return section this way is that I&#039;ve used the error logging proc as a form a of debug; if a condition occurs that I want to be logged but I don&#039;t want to return an error, I set @returnError = 1 and @forceExit = 0.

To your point, you could modify the error proc to return -1 and have your application check for and handle errors based on the return value.  This just depends on your application preferences.</description>
		<content:encoded><![CDATA[<p>Hi Jamie,</p>
<p>The error proc, dba_logError_sp , will indeed return the error to the calling app if @returnError = 1, which is the default behavior.  </p>
<p>    /* Should we return an error message to the calling proc? */<br />
    IF @returnError = 1<br />
        RAISERROR<br />
        (<br />
              @errorReturnMessage<br />
            , @errorReturnSeverity<br />
            , 1<br />
        ) WITH NOWAIT;</p>
<p>The reason I wrote the return section this way is that I&#8217;ve used the error logging proc as a form a of debug; if a condition occurs that I want to be logged but I don&#8217;t want to return an error, I set @returnError = 1 and @forceExit = 0.</p>
<p>To your point, you could modify the error proc to return -1 and have your application check for and handle errors based on the return value.  This just depends on your application preferences.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie Thomson</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-83</link>
		<dc:creator>Jamie Thomson</dc:creator>
		<pubDate>Sun, 21 Dec 2008 12:29:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-83</guid>
		<description>In the code above I think I&#039;m writing in saying that whoever called the sproc where the error occurred would never know about the error - hence they would assume that whatever activity they were doing had been committed. This strikes me as being a very bad thing.
There needs to be a way of reporting back to the caller than error occurred. Logging the error is all well and good (and very much best practice) but you MUST report back to the caller. As a rule I catch the error, log it, and then rethrow it back to the caller and have it handled at the top of the call stack - probably by reporting it back to the person that instigated the activity.

-Jamie</description>
		<content:encoded><![CDATA[<p>In the code above I think I&#8217;m writing in saying that whoever called the sproc where the error occurred would never know about the error &#8211; hence they would assume that whatever activity they were doing had been committed. This strikes me as being a very bad thing.<br />
There needs to be a way of reporting back to the caller than error occurred. Logging the error is all well and good (and very much best practice) but you MUST report back to the caller. As a rule I catch the error, log it, and then rethrow it back to the caller and have it handled at the top of the call stack &#8211; probably by reporting it back to the person that instigated the activity.</p>
<p>-Jamie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Dyckes</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-79</link>
		<dc:creator>Stephen Dyckes</dc:creator>
		<pubDate>Fri, 19 Dec 2008 19:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-79</guid>
		<description>Thanks for a great reminder about my lack of error handling. It lays out a great method for SQL2005. Too bad I am still stuck in 2000 with most of my environmnents, but there are ways to handle it there as well.</description>
		<content:encoded><![CDATA[<p>Thanks for a great reminder about my lack of error handling. It lays out a great method for SQL2005. Too bad I am still stuck in 2000 with most of my environmnents, but there are ways to handle it there as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michelle Ufford</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-75</link>
		<dc:creator>Michelle Ufford</dc:creator>
		<pubDate>Wed, 17 Dec 2008 15:17:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-75</guid>
		<description>Thanks for the head&#039;s up, Rob!  I&#039;ll take a look and see if I can fix it.</description>
		<content:encoded><![CDATA[<p>Thanks for the head&#8217;s up, Rob!  I&#8217;ll take a look and see if I can fix it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Boek</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-74</link>
		<dc:creator>Rob Boek</dc:creator>
		<pubDate>Wed, 17 Dec 2008 15:05:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-74</guid>
		<description>Those code boxes give very strange results in Google Reader.</description>
		<content:encoded><![CDATA[<p>Those code boxes give very strange results in Google Reader.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLBatman</title>
		<link>http://sqlfool.com/2008/12/error-handling-in-t-sql/comment-page-1/#comment-73</link>
		<dc:creator>SQLBatman</dc:creator>
		<pubDate>Wed, 17 Dec 2008 14:51:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=254#comment-73</guid>
		<description>nice post. this is often one of the things i find lacking in dev code and i try to explain why it is so important. typically it takes an &quot;incident&quot; in order to hammer home the point.</description>
		<content:encoded><![CDATA[<p>nice post. this is often one of the things i find lacking in dev code and i try to explain why it is so important. typically it takes an &#8220;incident&#8221; in order to hammer home the point.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
