Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a SQL Server Error Description

Status
Not open for further replies.

Ovatvvon

Programmer
Joined
Feb 1, 2001
Messages
1,514
Location
US
Hello All,

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)


-Ovatvvon :-Q
 
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


-Ovatvvon :-Q
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top