Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 error description

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-28 : 09:05:52
Andrea writes "I'd like to know how I can get the error description related to an error code.
In other words, if an error occurs during the execution of a stored procedure, I can detect its code by testing the value of @@error.
Once I've detected the error code I would like to store the corresponding description with the placeholders replaced by the current values.

EX:

error code: 2627
description: Violation of %ls constraint '%.*ls'. Cannot insert duplicate key in object '%.*ls'.
Table Name: ANDREA
Primary Key: PK1

When the error 2627 occurs I would like to get the description

-Violation of primary constraint PK1. Cannot insert duplicate key in object ANDREA-
and put it into a local variable.

My goal is tracing all the errors, included the description, occured during the execution of a stored procedure and,after failing the attempt I've described above, I also tried to configure the SQL Profiler in order to achieve it.
Even in this situation I didn't manage to detected the error description.

Can you give me a piece of advice ?"
   

- Advertisement -