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)
 Primary Key Violation error code

Author  Topic 

hasanali00
Posting Yak Master

207 Posts

Posted - 2005-04-18 : 10:22:40
I was told that the primary_key violation error code is 2601.
I was developing a asp.net application, so I tried to catch this code inside my app:
catch (SqlException e)
if (e.Number == 2601).....

However, this was not working. While debuging my app, I found out that the error code being returned was 2627.

When I used 2627 in my app, I was able to catch primary_key violation.

So my question is: IS 2627 official error code for primary_key violation, OR will it change according to individual SQL Servers??

thanks

mfemenel
Professor Frink

1421 Posts

Posted - 2005-04-18 : 10:46:03
You can check this in BOL. 2601 is the violation of a unique index, not necessarily a primary key. 2627 is the violation of a unique constraint, which would include the primary key.

Mike
"oh, that monkey is going to pay"
Go to Top of Page
   

- Advertisement -