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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to crack the error code

Status
Not open for further replies.

rochana

Programmer
Jan 28, 2004
2
AU
Hi Everyone!

In my stored procedure I check for any errors during .
If there are any errors I log them. (by checking @@ERROR)

What my problem is, the error message that's been logged contain place holders like %s, %l, %d,etc. along with the error message.

How can I get the full error message, with place holders replaced by real error values/text?

Here is a sample what I get as the error:

* Error ID: 547
* Error Desc: %ls statement conflicted with %ls %ls constraint '%.*ls'. The conflict occurred in database '%.*ls', table '%.*ls'%ls%.*ls%ls.

using this query
Code:
SELECT @errdesc=description FROM master.dbo.sysmessages WHERE error = @errid

When I run the stored proc in Query Analyser it gives the actual error message as:

Server: Msg 547, Level 16, State 1, Procedure sp_register_change, Line 366
INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_TBL_EQUIPMENT'. The conflict occurred in database 'EquipManT', table 'TBL_EQUIPMENT', column 'unitno'.
The statement has been terminated.



Thanks heaps,

rochana
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top