Connecting Tech Pros Worldwide Forums | Help | Site Map

Violation of Unique Key contraint during update

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 18 '09
I'm using a Unique Key constraint for the first time, and I think I may not be understanding something correctly. I have a table with a Primary key (media_format_id) that is auto-increment. Then I have 3 fields which are Foreign Keys, that I also added a Unique constraint to. I do not want any 2 records with the same value combination for those three fields (media_id, format_id, lang_id).

Here is the sp_help for my table (view attached image):
IX_multimedia_formats
nonclustered, unique, unique key located on PRIMARY media_id, format_id, lang_id

PK_multimedia_formats
clustered, unique, primary key located on PRIMARY media_format_id

I use a stored procedure to create the records, and another to update them. Create works fine (unique constraint and all), but during update, I get the Violation of Unique Key contraint error every time.

Can anyone point me in the right direction ? Thank you
Attached Thumbnails
sp_help.jpg  

Newbie
 
Join Date: Sep 2009
Posts: 2
#2: Sep 18 '09

re: Violation of Unique Key contraint during update


I found the problem. It was in the update stored procedure. My where clause syntax had an error.
Reply

Tags
constraint, sql