|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:10 PM
Points: 7,185,
Visits: 7,285
|
|
Nice interesting question.
I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.
If people have run the code and got 14 for erros state, what's going on? I would expect to see 14 only if THROW was called without any parameters (to rethrow the previous error).
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
http://es.linkedin.com/in/tomthomsonsoftware
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,373,
Visits: 896
|
|
L' Eomot Inversé (2/20/2013) Nice interesting question.
I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.
+ 1
Thanks for the question on a 2012 feature.
Oh no, we're toast! I've got this. *Keyboard clatter* Woah, how'd you do that? I'm a DBA...Booyah
Yeah, uh huh, you know what it is. Everything I do, I do it big

|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Today @ 6:50 PM
Points: 774,
Visits: 1,504
|
|
L' Eomot Inversé (2/20/2013) Nice interesting question.
I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.
If people have run the code and got 14 for erros state, what's going on? I would expect to see 14 only if THROW was called without any parameters (to rethrow the previous error).
I think people said they got severity level 14, not error state 14. They must be looking at the results of the SELECT in the CATCH block, which does show Level = 14, rather than the error message returned by the THROW statement, which always shows "Level 16" as its defined behavior.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 12:17 PM
Points: 856,
Visits: 1,279
|
|
| Awesome, thanks for the question on new 2012 functionality.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 6:17 AM
Points: 863,
Visits: 426
|
|
I'm having a senior blonde moment here...
What is the difference between: THROW returns the same error message as the select statement and THROW returns the error message "why oh why do you do this"
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 11:48 AM
Points: 2,602,
Visits: 1,553
|
|
| Thanks for the 2012 question.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Today @ 6:50 PM
Points: 774,
Visits: 1,504
|
|
batgirl (2/20/2013) I'm having a senior blonde moment here...
What is the difference between: THROW returns the same error message as the select statement and THROW returns the error message "why oh why do you do this"
The SELECT statement returns one row with four columns. The value in the unnamed fourth column is the text returned by the ERROR_MESSAGE() function, i.e., the standard "violation of primary key" message.
The THROW statement doesn't return rows but generates a message that includes the string 'why oh why do you do this', which was the [message] argument to the THROW statement.
THROW therefore does not return the same "error message" as the SELECT, but does return "why oh why do you do this".
Does that clear it up?
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 6:17 AM
Points: 863,
Visits: 426
|
|
wolfkillj (2/20/2013)
batgirl (2/20/2013) I'm having a senior blonde moment here...
What is the difference between: THROW returns the same error message as the select statement and THROW returns the error message "why oh why do you do this"The SELECT statement returns one row with four columns. The value in the unnamed fourth column is the text returned by the ERROR_MESSAGE() function, i.e., the standard "violation of primary key" message. The THROW statement doesn't return rows but generates a message that includes the string 'why oh why do you do this', which was the [message] argument to the THROW statement. THROW therefore does not return the same "error message" as the SELECT, but does return "why oh why do you do this". Does that clear it up?
Yes - I was woefully short on caffeine when I wondered this. Some days "senior" and "blonde" is an insurmountable combination 
Thanks so much!
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 8:35 AM
Points: 212,
Visits: 195
|
|
wolfkillj (2/20/2013)
L' Eomot Inversé (2/20/2013) Nice interesting question.
I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.
If people have run the code and got 14 for erros state, what's going on? I would expect to see 14 only if THROW was called without any parameters (to rethrow the previous error).I think people said they got severity level 14, not error state 14. They must be looking at the results of the SELECT in the CATCH block, which does show Level = 14, rather than the error message returned by the THROW statement, which always shows "Level 16" as its defined behavior.
Hey from BOL, I was infering that when THROW is used in a catch block without any parameters, it returns the level of the actual error raised in the try block and not 16...
Please let me know if I am right?
___________________________________________________________________ If I can answer a question then anyone can answer it..trying to reverse the logic..
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Today @ 6:50 PM
Points: 774,
Visits: 1,504
|
|
venkat9.sql (2/20/2013)
wolfkillj (2/20/2013)
L' Eomot Inversé (2/20/2013) Nice interesting question.
I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.
If people have run the code and got 14 for erros state, what's going on? I would expect to see 14 only if THROW was called without any parameters (to rethrow the previous error).I think people said they got severity level 14, not error state 14. They must be looking at the results of the SELECT in the CATCH block, which does show Level = 14, rather than the error message returned by the THROW statement, which always shows "Level 16" as its defined behavior. Hey from BOL, I was infering that when THROW is used in a catch block without any parameters, it returns the level of the actual error raised in the try block and not 16... Please let me know if I am right?
I don't think that's right. BOL specifies that THROW can be called without parameters only in a CATCH block, and also that severity is ALWAYS set to 16 with THROW. Source: http://msdn.microsoft.com/en-us/library/ee677615.aspx
|
|
|
|