dbTalk Databases Forums  

Duplicate Key Skip?

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


Discuss Duplicate Key Skip? in the microsoft.public.sqlserver.dts forum.



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

Default Duplicate Key Skip? - 04-28-2006 , 03:39 PM






I am trying to use DTS to copy from an Excel file to a table (SQL 2000).
The table has a primary key (say ID). As might be expected, when a
duplicate key is detected, it terminates the copy. With Access one could
use First/INTO/Group and have the copy just skip the duplicate. I cannot
use DISTINCT since the key may be duplicated but the name might not be.

How does on accomplish this using SQL Server?

Thanks.

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

Default Re: Duplicate Key Skip? - 04-28-2006 , 04:03 PM






The problem here then is that what one system calls a key is not what the
other one defines as a key.. In the Access method surely you are ignoring
rows of data. How do you decide which row with the same key is for the chop
or is it arbitrary?

You can do this a number of ways and these range from using Lookups within
the pump to see if you already have the value in the destination to pumping
to a working table and then using something like MIN or MAX to get a row
with the same key value. There are other ways as well.



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"MikeV06" <me (AT) privacy (DOT) net> wrote

Quote:
I am trying to use DTS to copy from an Excel file to a table (SQL 2000).
The table has a primary key (say ID). As might be expected, when a
duplicate key is detected, it terminates the copy. With Access one could
use First/INTO/Group and have the copy just skip the duplicate. I cannot
use DISTINCT since the key may be duplicated but the name might not be.

How does on accomplish this using SQL Server?

Thanks.



Reply With Quote
  #3  
Old   
MikeV06
 
Posts: n/a

Default Re: Duplicate Key Skip? - 04-29-2006 , 10:20 AM



On Fri, 28 Apr 2006 17:03:12 -0400, Allan Mitchell wrote:

Quote:
The problem here then is that what one system calls a key is not what the
other one defines as a key.. In the Access method surely you are ignoring
rows of data. How do you decide which row with the same key is for the chop
or is it arbitrary?

You can do this a number of ways and these range from using Lookups within
the pump to see if you already have the value in the destination to pumping
to a working table and then using something like MIN or MAX to get a row
with the same key value. There are other ways as well.
Thanks. I ended up writing a quick VB Script using a save variable to see
if the attribute had changed and if it had not, just skipped that record.


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.