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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-21 : 09:15:41
|
| Manish writes "Hi Friend,Question Suppose, I have created a table with two fields say, EmpID and EmpNm with EmpID as PRIMARY KEY and EmpNm UNIQUE Constraint. Now I INSERT the values first ('E01', 'Manish') it works fine. Now, again I INSERT the values ('E01', 'Manish') it wil give an error. Now the problem is both returns the same error no. with different Severity and State. We can capture error by @@ERROR but how to capture Severity and State? How to find whether the error occured is coz of Primary key or Unique key?Thanx" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-21 : 10:56:10
|
| It really doesn't matter WHICH constraint is violated. As far as I know you can't determine severity or state without some advanced error message technique. You can find some methods for this on [url]http://www.nigelrivett.com[/url]. It may not provide the information you need, but it's the best shot you have.If you need to know which constraint is violated, you're better off testing for possible duplicates BEFORE performing the insert, instead of trying to catch an error. |
 |
|
|
|
|
|