February 24, 2003 at 3:42 am
In case of error in a statement SQL (update, insert, ecc)....
From T-SQL code, exists a method to recover the error message and,
(for example) setting a variable (of type varchar) with this message??
Help me, Thanks!
Flavio
February 24, 2003 at 12:28 pm
All the predefined error messages are stored in master.dbo.sysmessagess. You can get error code from @@ERROR, save it in a local variable, then select from that table where error = loca variable. Of course, this won't return specifics of the message (table name, etc.), just a template.
I would use the middle tier application to read the error text from your OLEDB provider.
Michael
February 24, 2003 at 1:17 pm
If the error is in the sysmessages you can use FORMATMESSAGE
From BOL:
quote:
This example uses a hypothetical message 50001, stored in sysmessages as "The number of rows in %s is %1d." FORMATMESSAGE substitutes the values Table1 and 5 for the parameter placeholders. The resulting string, "The number of rows in Table1 is 5." is stored in the local variable @var1.DECLARE @var1 VARCHAR(100)
SELECT @var1 = FORMATMESSAGE(50001, 'Table1', 5)
Tim C.
//Will write code for food
Tim C //Will code for food
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply