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.
| Author |
Topic |
|
peddi_praveen
Starting Member
48 Posts |
Posted - 2002-12-18 : 23:17:17
|
| Hi Guys, I need to track the error message in my application.Situation like this:Create Table1(PK_T1 int, col2 varchar(10) ) Create Table2(PK_T2 int, col2 varchar(10) )Create Table3(PK_T3 int, PK_T1 int NOT NULL, FK_to_table1 PK_T2 int NOT NULL, FK_to_table2)Usually, whtle inserting data to table 3 from QA , if any FK column data is missing, SQL SERVER gives error message statingERROR CODE : 547ERROR MESSAGE: INSERT Stmt failed bcause FK_to_XXXXXX constraint is failing.......For My application, i need to log the error message to identify which FK is causing the errorUsing @@ERROR, i can identify wat is the error code, but,is there any way to track the error message as well.thnx n regs,praveen |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-12-18 : 23:25:09
|
| Nigel has some code here:http://www.nigelrivett.com/That can retrieve the error message from the output buffer. |
 |
|
|
skillile
Posting Yak Master
208 Posts |
Posted - 2002-12-18 : 23:27:54
|
| How about using:RAISERROR or sp_addmessageor you could check the values of the @'s before insert and bypass the error.slow down to move faster... |
 |
|
|
peddi_praveen
Starting Member
48 Posts |
Posted - 2002-12-18 : 23:34:30
|
| hi guys,thnx for response,Iam able to track ERROR CODE using @@ERROR inside SP, which gives me 547 for all FK failures, i also need to track which FK exactly causing the error, which i can not just by error code 547.regs,praveen |
 |
|
|
peddi_praveen
Starting Member
48 Posts |
Posted - 2002-12-18 : 23:39:08
|
| Hi sKillile,In fact, i need this one to debug my SP as iam confiDdent that tthe values being passed in are correct as that is taken care from my application/UI side. Still i got this error, so, i want to know which FK is causing error.Thnx n Regs,Praveen |
 |
|
|
|
|
|
|
|