April 17, 2008 at 8:23 am
Does anyone know how to get the description text of a SQL Error (eg. "Primary Key violation of ..") into a variable. Like @@ERROR holds the error number, where is the error text?
Patrick SIMONS, MCP
April 17, 2008 at 8:47 am
PatrickSimons (4/17/2008)
Does anyone know how to get the description text of a SQL Error (eg. "Primary Key violation of ..") into a variable. Like @@ERROR holds the error number, where is the error text?
Unfortunately under SQL Server 2000 you can only use @@ERROR (there is nothing like @@ERROR_MESSAGE). Based on this number you could get more information from master..sysmessages, but these are templates only (with placeholders for object names, ...)
SQL Server 2005 has improved on this, so in the future when your systems are upgraded you will be able to get the error message.
Regards,
Andras
April 18, 2008 at 3:54 am
Andras,
Concur.
karthik
April 18, 2008 at 5:13 am
Found a script that works using DBCC OUTPUTBUFFER
http://www.sommarskog.se/error-handling-I.html#textretrieve
Patrick SIMONS, MCP
April 18, 2008 at 5:17 am
PatrickSimons (4/18/2008)
Found a script that works using DBCC OUTPUTBUFFER
This is indeed a very nice solution, but it comest at a rather high cost (not only it is not 100% reliable, it requires sysadmin privileges :)). Is it really worth?
Regards,
Andras
April 18, 2008 at 6:43 am
Any idea how to clean/initialize the outputbuffer?
Patrick SIMONS, MCP
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply