﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by wall str33t  / what does the second @@error return? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 12:50:29 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Previous question also same like this.... easy only.....ManikGo fast as possible</description><pubDate>Fri, 01 Feb 2013 05:45:46 GMT</pubDate><dc:creator>manik123</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>@@error will have the right error code if selected immediately after raiserror commandraiserror('oh no, another error!', 16,1)select @@errorThanks</description><pubDate>Wed, 21 Mar 2012 17:33:59 GMT</pubDate><dc:creator>IgorMi</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Thanx Dear for ur ans.</description><pubDate>Tue, 18 May 2010 05:54:29 GMT</pubDate><dc:creator>suryam</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Select 'xyz' will not return any error.so @@error return 0</description><pubDate>Tue, 27 Apr 2010 05:05:27 GMT</pubDate><dc:creator>preeti.singh</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>[quote][b]Lynn Pettis (4/26/2010)[/b][hr]What is interesting is that approximately a third of the respondents have gotten the question wrong.[/quote]I'm amongst that respondents because I haven't used @@error since 2006, and I've already forgotten about this function :-)</description><pubDate>Tue, 27 Apr 2010 01:02:59 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Return 0 because there is a statement between (select 'xyz'), and this statement do not raise error</description><pubDate>Mon, 26 Apr 2010 22:57:59 GMT</pubDate><dc:creator>MIGUEL PEGUERO</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Second error return 50000(1 row(s) affected)Msg 50000, Level 16, State 1, Line 2oh no, error!(1 row(s) affected)(1 row(s) affected)Msg 50000, Level 16, State 1, Line 6oh no, another error!(1 row(s) affected)</description><pubDate>Mon, 26 Apr 2010 22:53:17 GMT</pubDate><dc:creator>MIGUEL PEGUERO</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>(1 row(s) affected)Msg 50000, Level 16, State 1, Line 2oh no, error!(1 row(s) affected)(1 row(s) affected)Msg 50000, Level 16, State 1, Line 6oh no, another error!(1 row(s) affected)</description><pubDate>Mon, 26 Apr 2010 22:52:24 GMT</pubDate><dc:creator>MIGUEL PEGUERO</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>What is interesting is that approximately a third of the respondents have gotten the question wrong.</description><pubDate>Mon, 26 Apr 2010 15:13:48 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>[quote][b]Mohamed-401375 (4/26/2010)[/b][hr]Nice question.Tricky though. Makes you read closely.[/quote]I agree.  My first reaction was that the two "raiseerror' invocations were identical.   But then I did look more closely and realized that the question was not about "raiseerror" but rather was on "@@error".  Once I saw that, the answer was obvious.  Perhaps anyone saying this was a confusing, and therefore sub-standard, QOD should consider whether their confusion was borne of their own haste.</description><pubDate>Mon, 26 Apr 2010 13:20:48 GMT</pubDate><dc:creator>john.arnott</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Nice question.Tricky though. Makes you read closely.</description><pubDate>Mon, 26 Apr 2010 12:52:22 GMT</pubDate><dc:creator>Mohamed-401375</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Good question, I liked it. Starting from SQL Server 2005, getting the error information from the @@error is certainly becoming less popular due to availability of the structured error handling via try/catch blocks and functions like error_number(), error_message() and error_line(), but it is still good to know and understand the behavior of the good old friend @@error.Oleg</description><pubDate>Mon, 26 Apr 2010 09:46:31 GMT</pubDate><dc:creator>Oleg Netchaev</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>I like the question.  Nice job.</description><pubDate>Mon, 26 Apr 2010 08:54:29 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Good question. The phrasing could have been more precise, such as what does the second 'select @@error' statement return, but I think that is beside the point and should not be grounds for criticizing the question. I just plain missed that the select 'xyz' statement resets the @@error value to 0, so it was a good exercise in reading code more carefully.Thanks,webrunner</description><pubDate>Mon, 26 Apr 2010 08:41:37 GMT</pubDate><dc:creator>webrunner</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Good question!I purposely did [i]not[/i] run this in Query Editor, and tried to answer on my own.  (I got it right!)I had to keep in mind that @@ERROR really only applies to the most recent line.  From what I saw, SELECT 'XYZ' would not return an error!</description><pubDate>Mon, 26 Apr 2010 08:28:06 GMT</pubDate><dc:creator>Ray K</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>I didn't have to run the code to know the answer, but, what if I did? It still would be a learning experience which is the point of the QotD. I find the negativity against running code to be irritating.Good question, though. Nicely thought out and very clear as to its intent. :-)</description><pubDate>Mon, 26 Apr 2010 08:19:12 GMT</pubDate><dc:creator>OCTom</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>While I see that the answer is correct, I found the question to be confusing, therefore I feel that it was not a good question.</description><pubDate>Mon, 26 Apr 2010 08:14:28 GMT</pubDate><dc:creator>Patrick Cahill</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>A question about SQL today!  Well done, and thanks.@@error is a bit less relevant these days (TRY/CATCH) but it's still a good general-knowledge question.</description><pubDate>Mon, 26 Apr 2010 05:16:46 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>hi,yes correcti missunderstood the questionmeans i haven't read the question correctly</description><pubDate>Mon, 26 Apr 2010 04:10:09 GMT</pubDate><dc:creator>charles.prabhu</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Did this without query analyser.. and got it right, nice.Hi wall str33t, Nice question!Hi Charles,Both queries will give the same error, but the question was asking what was returned in the results, not the messages.The first query when ran by itself will error (you get messages), and the results panel will show two result sets, the first 'abc' , the second the error result set with the error number.The second query will have three result sets:'abc''xyz'and 0Because as wall str33t says the second query executes fine, clears @@error, therefore no error is held in the @@error variable when selected.</description><pubDate>Mon, 26 Apr 2010 04:00:27 GMT</pubDate><dc:creator>Fozzie</dc:creator></item><item><title>RE: what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>hi,the below given set of statements given the same error...:hehe:select 'def'raiserror('oh no, another error!', 16,1)select 'xyz'select @@error(1 row(s) affected)Msg 50000, Level 16, State 1, Line 2oh no, another error!(1 row(s) affected)(1 row(s) affected)</description><pubDate>Mon, 26 Apr 2010 02:24:15 GMT</pubDate><dc:creator>charles.prabhu</dc:creator></item><item><title>what does the second @@error return?</title><link>http://www.sqlservercentral.com/Forums/Topic910074-2682-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/%40%40error/69773/"&gt;what does the second @@error return?&lt;/A&gt;[/B]</description><pubDate>Sat, 24 Apr 2010 19:41:50 GMT</pubDate><dc:creator>wall str33t</dc:creator></item></channel></rss>