You can use @@ERROR to get the error number in a stored procedure, but is there a way to get a description of that error? (i.e. @@ERROR_DESCRIPTION...even though that one doesn't work)
I'm not sure if it is the best way but I've always returned the description from teh sysmessages table which you can easily query on the error number returned
____________ signature below ______________
General FAQ faq333-2924
5 steps to asking a question faq333-3811
Hmm, that does show messags that correlate to the error number, but, there seems to be a bunch of messages that are garbled. There are many languages for each error, but even specifying the English one (1033), some of them are still garbled. Any idea what that's about?
For Instance, I don't know how it is on yours, but my error message for 15151 is like the following:
Code:
select *
from sysmessages
where msglangid=1033
AND error = 15151
Code:
15151
16
0[COLOR=red]
Cannot %S_MSG the %S_MSG '%.*ls', because it does not exist or you do not have permission.[/color]
1033
it's not garble. Those are place holders that sql server uses to input values from the error when it happens. I wrote a long winded SP a long time ago to use those place holders and regular expressions to use the descriptions in a similar way that sql server does. that was pretty much the point of my statement of, "Not sure if it's the best way"
The table I have for all the place holders is in a manual but I'm sure you can find one online. The main ones are "%d" = number, "%S_MSG" = db object, "%.*s" is the name of the object.
____________ signature below ______________
General FAQ faq333-2924
5 steps to asking a question faq333-3811
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.