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 Administration (2000)
 Another Error Statement

Author  Topic 

rardales
Starting Member

32 Posts

Posted - 2005-04-01 : 13:19:11
Geez, I got another error message after attempting to run another update statement:

Server: Msg 2627, Level 14, State 1, Procedure tu_work_comp_claimant, Line 71
Violation of PRIMARY KEY constraint 'XPK_work_comp_claimant_log'. Cannot insert duplicate key in object 'work_comp_claimant_log'.
The statement has been terminated.


Here's the code I ran:

update work_comp_claimant
set benefit_type_code ='05'
where benefit_type_code = '11'


Any ideas on how to get it to work?

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-04-01 : 13:30:59
Looks like the work_comp_claimant table has a trigger that copies any records that have been updated to the work_comp_claimant_log table. I guess you have to drop the PRIMARY KEY constraint in your work_comp_claimant_log table because it is used to store the changes in the work_comp_claimant table and doesn't need a PRIMARY KEY.
Go to Top of Page

rardales
Starting Member

32 Posts

Posted - 2005-04-01 : 13:36:38
What would be the easiest and safest way to do this? Also, would it be a good idea to re-apply the primary key after the update statement?
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-04-04 : 02:48:35
check for the constraints,

determine if this query is valid based on these constraints if any,

if query is valid, check for the duplicate values and resolve.

removing the constraint is not the solution, you'll get into a lot of trouble if you ignore the constraints, actually that's one of the reasons why you place them in there the first time.

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

- Advertisement -