Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An Error Number

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
US
Is there a way to log an error number and the message associated with that error number into a table that is created in a stored procedure?

I wanted to create a table to log any errors that occur during the execution of the stored procedure.

I wanted to log the error number and error message.
 
Hi there,
You may need not to store the error description in your table. because the system's generated error messages are already stored in sysmessages table in master database.
so what all you require is to store the error no.
which you can do in following way...
--------------
... sql statements in the procedure ...
if error<>0
insert in myErrorTable (error) VALUES(error)
--------------
Later on you can check the description by issuing
select a.error, b.description
from myErrorTable a, master..sysmessages b
where a.error=b.error


But, It requires to write the if error statement after each sql statement. So, it is easier to control it from the frontend. All the front ends receive the error no and its description from the sql whenever an error is generated. Just check if there is any error and if yes store it into your error table.

Hope this will move you in right direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top