dbTalk Databases Forums  

Duplicate Primary Keys?

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


Discuss Duplicate Primary Keys? in the microsoft.public.sqlserver.dts forum.



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

Default Duplicate Primary Keys? - 07-21-2003 , 12:05 PM






I am trying to copy data from one SQL server to another (hopefully on a
schedule soon). Anyhow when I run it, I get the following error:

Error at Destination for Row number 246271. Errors encountered so far in
this task: 1.
The statement has been terminated.
Violation of PRIMARY KEY constraint 'PK_CART'. Cannot insert duplicate key
in object 'Cart'.

Ok, I understand what the error means. Essentially there is a duplicate
(autoincremented) primary key, which, in itself, seems like it should not be
possible. But lets just say, it is (well yea it is). How do I correct
this? The issue here is 2 fold..

1. If I do have a primary key violation in a table, how do I fix it? I get
no indication of what row the violation is in. In addition, how could this
happen anyhow?

2. Why do I get this error from DTS? I thought DTS would copy virtually the
entire table, structure and all. If the source DB is in one state (errors
or not) why would the DTS be unable to duplicate it? And finally, how do I
avoid having DTS dump when it hits an error like this? I'd rather just omit
the problematic erros rather than have a totally bad copy of the database.

THANKS FOR THE HELP!! This is very appreciated!

Jon



Reply With Quote
  #2  
Old   
JFB
 
Posts: n/a

Default Re: Duplicate Primary Keys? - 07-21-2003 , 03:18 PM






Hi Jon,
You can skip the duplicate row or import the row creating a new key in the
transformation task properties using lookups.
Example
http://www.sqldts.com/default.aspx?6,107,277,7,1
JFB

"Jon Glazer" <jglazer.deleteme (AT) adconn (DOT) com> wrote

Quote:
I am trying to copy data from one SQL server to another (hopefully on a
schedule soon). Anyhow when I run it, I get the following error:

Error at Destination for Row number 246271. Errors encountered so far in
this task: 1.
The statement has been terminated.
Violation of PRIMARY KEY constraint 'PK_CART'. Cannot insert duplicate
key
in object 'Cart'.

Ok, I understand what the error means. Essentially there is a duplicate
(autoincremented) primary key, which, in itself, seems like it should not
be
possible. But lets just say, it is (well yea it is). How do I correct
this? The issue here is 2 fold..

1. If I do have a primary key violation in a table, how do I fix it? I
get
no indication of what row the violation is in. In addition, how could
this
happen anyhow?

2. Why do I get this error from DTS? I thought DTS would copy virtually
the
entire table, structure and all. If the source DB is in one state (errors
or not) why would the DTS be unable to duplicate it? And finally, how do
I
avoid having DTS dump when it hits an error like this? I'd rather just
omit
the problematic erros rather than have a totally bad copy of the database.

THANKS FOR THE HELP!! This is very appreciated!

Jon





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

Default Re: Duplicate Primary Keys? - 07-22-2003 , 01:48 AM



You can do a series of comparisons using TSQL looking for comparisons on the
PKs

Also you may like to investigate

Multiphase Data Pump (Field Notes)
http://www.sqldts.com/default.aspx?6,107,282,7,1

--

----------------------------
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



"Jon Glazer" <jglazer.deleteme (AT) adconn (DOT) com> wrote

Quote:
I am trying to copy data from one SQL server to another (hopefully on a
schedule soon). Anyhow when I run it, I get the following error:

Error at Destination for Row number 246271. Errors encountered so far in
this task: 1.
The statement has been terminated.
Violation of PRIMARY KEY constraint 'PK_CART'. Cannot insert duplicate
key
in object 'Cart'.

Ok, I understand what the error means. Essentially there is a duplicate
(autoincremented) primary key, which, in itself, seems like it should not
be
possible. But lets just say, it is (well yea it is). How do I correct
this? The issue here is 2 fold..

1. If I do have a primary key violation in a table, how do I fix it? I
get
no indication of what row the violation is in. In addition, how could
this
happen anyhow?

2. Why do I get this error from DTS? I thought DTS would copy virtually
the
entire table, structure and all. If the source DB is in one state (errors
or not) why would the DTS be unable to duplicate it? And finally, how do
I
avoid having DTS dump when it hits an error like this? I'd rather just
omit
the problematic erros rather than have a totally bad copy of the database.

THANKS FOR THE HELP!! This is very appreciated!

Jon





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.