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
 Transact-SQL (2000)
 Server: Msg 2627...Violation of PRIMARY KEY

Author  Topic 

erncelen
Starting Member

15 Posts

Posted - 2005-07-02 : 07:06:42
For some tables (but not all) SQL Query analyzer output the follwing message:

(This happen during update)

Server: Msg 2627, Level 14, State 1, Line 4

Violation of PRIMARY KEY constraint 'PK_BP_STEP_LINKS'. Cannot insert duplicate key in object 'BP_STEP_LINKS'.
The statement has been terminated.

I have added ALTER TABLE tablename NOCHECK CONSTRAINT ALL
and
ALTER TABLE krna_mcocore43Import.dbo.BP_STEP_LINKS CHECK CONSTRAINT ALL

at the beginning and at the end of UPDATE statement


How can I solve this problem?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-02 : 07:23:35
It is because you are updating that column with the value which that column already has
You need to check the existance of the value before updating it
Can you post the full update statement you used?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-07-04 : 22:03:54
are you sure you want to override the constraint?

i assume, the PK was created to prevent duplicate records?

solution: remove the constraint or check the value you're trying to update

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -