November 14, 2003 at 7:51 am
@@ERROR only indicates an error has occurred. How do you capture the corresponding error string (which is usually printed in query analyzer)? I am not looking for the text representation of error xyz, but instead the string which contains the runtime error message.
Is there a different variable which holds this information?
Regards,
Joshua
November 14, 2003 at 8:07 am
Not sure if I understand.
Are you searching for the table sysmessages in master?
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 14, 2003 at 8:19 am
Your right, I should clarify.
I have a stored procedure which converts data, essentially moving it from one table to another. I check the @@error variable to detect when my logic fails (an insert for example) and rollback the transaction. I then log the problem in another table and continue processing.
If an insert (for example) failed because of a primary key constraint, it would be nice to know which constraint caused the problem for that particular row. I am looking to capture the runtime error that occurs for each iteration.
Any ideas?
November 14, 2003 at 10:42 am
Save @@ERROR in a @variable if is not 0 and then
select description from master.dbo.sysmessages where error = @variable
HTH
* Noel
November 14, 2003 at 11:40 am
sysmessages only contains the generic error message, without references to the particular objects.
For example: Unclosed quote before the character string %.*ls.
Is that specific enough?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply