April 18, 2011 at 5:54 am
Hello Friends,
I would like to know the way to get the error description associated with the error value which is returned by the statement Select @@ERROR
Please help me on this.
Thanks & Regards
Murali
April 18, 2011 at 6:11 am
Use try .... catch.
April 18, 2011 at 7:40 am
You should use TRY CATCH, but error messages are stored in sys.messages so you can get the description from there. You also need the language to limit the results. Here's an example:
DECLARE @error INT ;
SELECT
1 / 0 ;
SET @error = @@ERROR;
SELECT
*
FROM
sys.messages AS M
JOIN sys.syslanguages AS S
ON M.language_id = S.lcid
WHERE
M.message_id = @error AND
S.langid = @@LANGID ;
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 18, 2011 at 9:57 am
Thanks Ninja's_RGR'us & Jack for your responses. Got to know the information from your responses. [font="Arial"][/font]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply