Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

what does the second @@error return? Expand / Collapse
Author
Message
Posted Monday, April 26, 2010 9:46 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 11:47 AM
Points: 1,676, Visits: 1,759
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
Post #910495
Posted Monday, April 26, 2010 12:52 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, July 1, 2013 4:39 PM
Points: 889, Visits: 97
Nice question.
Tricky though. Makes you read closely.
Post #910625
Posted Monday, April 26, 2010 1:20 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 28, 2014 8:53 PM
Points: 1,388, Visits: 3,039
Mohamed-401375 (4/26/2010)
Nice question.
Tricky though. Makes you read closely.
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.
Post #910647
Posted Monday, April 26, 2010 3:13 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 1:42 AM
Points: 20,799, Visits: 32,717
What is interesting is that approximately a third of the respondents have gotten the question wrong.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #910733
Posted Monday, April 26, 2010 10:52 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 27, 2010 8:58 PM
Points: 6, Visits: 5
(1 row(s) affected)
Msg 50000, Level 16, State 1, Line 2
oh no, error!

(1 row(s) affected)

(1 row(s) affected)
Msg 50000, Level 16, State 1, Line 6
oh no, another error!

(1 row(s) affected)
Post #910818
Posted Monday, April 26, 2010 10:53 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 27, 2010 8:58 PM
Points: 6, Visits: 5
Second error return 50000

(1 row(s) affected)
Msg 50000, Level 16, State 1, Line 2
oh no, error!

(1 row(s) affected)

(1 row(s) affected)
Msg 50000, Level 16, State 1, Line 6
oh no, another error!

(1 row(s) affected)
Post #910819
Posted Monday, April 26, 2010 10:57 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 27, 2010 8:58 PM
Points: 6, Visits: 5
Return 0 because there is a statement between (select 'xyz'), and this statement do not raise error
Post #910823
Posted Tuesday, April 27, 2010 1:02 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
Lynn Pettis (4/26/2010)
What is interesting is that approximately a third of the respondents have gotten the question wrong.

I'm amongst that respondents because I haven't used @@error since 2006, and I've already forgotten about this function
Post #910853
Posted Tuesday, April 27, 2010 5:05 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 20, 2011 3:53 AM
Points: 54, Visits: 15
Select 'xyz' will not return any error.
so @@error return 0
Post #910958
Posted Tuesday, May 18, 2010 5:54 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 3:38 AM
Points: 165, Visits: 93
Thanx Dear for ur ans.

Thanks
Post #923482
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse