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 2008 Forums
 Transact-SQL (2008)
 Violation of UNIQUE KEY constraint

Author  Topic 

bobred
Starting Member

14 Posts

Posted - 2015-02-13 : 04:08:19
Hi

I am trying to update a field and I'm getting the error 'Violation of UNIQUE KEY constraint'. I have a temp table where the data to be updated is stored then I am using the following to update the other table

UPDATE [CostCentre] 
SET [CostCentreCode] = V.[CostCentreCode]
FROM [CostCentre] Y INNER JOIN [RCH Cost Centres] V
ON Y.[CostCentreId]=V.[CostCentreId]


I have checked and there are no constraints showing on this field or foreign keys.

Any ideas?

stepson
Aged Yak Warrior

545 Posts

Posted - 2015-02-13 : 04:31:34
Check for trigger on table CostCentre


sabinWeb MCP
Go to Top of Page

bobred
Starting Member

14 Posts

Posted - 2015-02-13 : 04:51:59
Hi

I found the problem, there was a duplicate in my source data, doh!

James
Go to Top of Page
   

- Advertisement -