dbTalk Databases Forums  

composite primary key insert violation

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss composite primary key insert violation in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Raul
 
Posts: n/a

Default composite primary key insert violation - 08-14-2003 , 09:18 AM






Hi,
I'm using SQL Server 2000 and created a simple DTS to append
records from one table to another.
The second table has got a composite primary key (col1 and col2).
When I run the DTS is gives me this error:
----------
Violation of Primary key constraint "PK_Table2". Cannot insert duplicate key
in object "Table2".
----------
This works fine in Access because the composite of the two columns
is not a duplicate, and those that are duplicates will be skipped.
Is there something I'm missing, or does SQL 2K not support
this feature in the same way Access does?
Would appreciate your help.
Thanks.
Raul



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: composite primary key insert violation - 08-14-2003 , 03:37 PM






If you want to push records to atable and you know the source contains
duplicates then you can look to use a UNIQUE index with IGNORE DUPLICATE
KEY values.
--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Raul" <raul (AT) tangible-results (DOT) com> wrote

Quote:
Hi,
I'm using SQL Server 2000 and created a simple DTS to append
records from one table to another.
The second table has got a composite primary key (col1 and col2).
When I run the DTS is gives me this error:
----------
Violation of Primary key constraint "PK_Table2". Cannot insert duplicate
key
in object "Table2".
----------
This works fine in Access because the composite of the two columns
is not a duplicate, and those that are duplicates will be skipped.
Is there something I'm missing, or does SQL 2K not support
this feature in the same way Access does?
Would appreciate your help.
Thanks.
Raul





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.