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 Handling - Determining which object cause the error

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-23 : 08:36:00
Alain writes "SQL Version : 2000 SP1
Windows : 2000 Professional SP2

I'm writing a stored procedure and I am handling the errors that might come up. I can get the error number thru @@Error like 547 (Constraint Violation) but it seems that it is still not specific. Is there a function that I can use which object (in this case, which constraint is violated) caused the errors so that I can give meaningful and more precise suggestion to the client apps who is using the SQL Server. Thanks A lot!"

fisherman_jake
Slave to the Almighty Yak

159 Posts

Posted - 2002-01-23 : 18:44:00
Alain,

If you don't already know this then check the sysmessages table..

select * from master..sysmessages

Then build whatever you want around it..

==================================================
World War III is imminent, you know what that means... No Bag limits!!!
Master Fisherman
Go to Top of Page

alainee
Starting Member

1 Post

Posted - 2002-01-23 : 19:10:06
Thanks for replying. I've already checked that one. I've noticed that SQL seems to dynamically replace the variables (%d, %.*ls) with the appropriate object name which caused the errors. Is there a function that I can get this object which cause it. Or I have to get a substring from the description and compare it with my objects. Tnx again.

Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2002-01-23 : 19:13:41
Alain,

Lookup RAISERROR in BOL, it will have all that you need....

DavidM

Tomorrow is the same day as Today was the day before.
Go to Top of Page
   

- Advertisement -