catching error messages in stored procs

catching error messages in stored procs

Post by Nathanael » Sat, 02 Aug 2003 02:28:46


I want to get the error text from an insert query that is
run within a stored procedure to save in an insert reject
table for later analysis.

I know how to check @@error and get the error number and
even look up the generic text in sysmessages, but I don't
know how to get the full message telling which constraint
was violated etc.

Can anyone help with this?
 
 
 

catching error messages in stored procs

Post by Wayne Snyd » Sat, 02 Aug 2003 02:36:02

You can't do it... sorry!

I support the Professional Association of SQL Server (PASS) and it community
of SQL Server professionals.
www.sqlpass.org

 
 
 

catching error messages in stored procs

Post by Martin Lin » Sat, 02 Aug 2003 17:37:35

In theory, you can get the whole error message through ADO objects, so if
you really must, create the necessary ADO objects in your SP, execute the
INSERT and look at the Errors collection ...
But I admit it is weird to use ADO inside an SP in order to connect to the
very database where the SP resides. I don't have any other ideas though.

Martin



community