SQL Server Composite Primary Keys

Posted by Colin on Stack Overflow See other posts from Stack Overflow or by Colin
Published on 2010-05-13T17:08:06Z Indexed on 2010/05/13 17:14 UTC
Read the original article Hit count: 182

Filed under:
|
|

I am attempting to replace all records for a give day in a certain table. The table has a composite primary key comprised of 7 fields. One such field is date.

I have deleted all records which have a date value of 2/8/2010. When I try to then insert records into the table for 2/8/2010, I get a primary key violation. The records I am attempting to insert are only for 2/8/2010.

Since date is a component of the PK, shouldn't there be no way to violate the constraint as long as the date I'm inserting is not already in the table?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008