Paul Nielsen
pauln at sqlserverbible.com
Wed Mar 19 17:28:28 CDT 2008
Hi Mark, I've done this many times. Use BulkInsert to bring the data into a staging table. Then clean it up during the move to the real tables by adding the PK and using the min(pk) method I sent earlier. -Paul -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Mark A Matte Sent: Wednesday, March 19, 2008 2:41 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Duplicate records Unfortunately the data comes in with dups...I have the final table indexed...I just have to clean it before inserting. Just looking at different approaches. Thanks, Mark A. Matte > Date: Wed, 19 Mar 2008 15:22:13 -0500 > To: dba-sqlserver at databaseadvisors.com > From: robert at webedb.com > Subject: Re: [dba-SQLServer] Duplicate records > > Mark, > > As other have said, cursors are slow. > > After you get it cleaned up, I would put a unique index on the 2 columns > so that the problem is solved permanently. > > Robert > > At 09:21 AM 3/19/2008, you wrote: >>Date: Tue, 18 Mar 2008 20:46:01 +0000 >>From: Mark A Matte >>Subject: [dba-SQLServer] Duplicate records >>To: Discussion concerning MS SQL Server >> >>Message-ID: >>Content-Type: text/plain; charset="iso-8859-1" >> >> >>Hello All, >> >>I have a large table that occasionally duplicates make it into. The >>2 fields that make the record unique are Case_ID and >>Note_Seq_Nbr. The duplicates are identical...so I have no primary >>key. I used the code below. It doesn't run very fast...but it does >>the job of removing just the extra records... >> >>Any thoughts,comments, or suggestions on making it >>faster/better...or a totally different approach? >> >>Thanks, >> >>Mark A. Matte > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ Climb to the top of the charts! Play the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com __________ NOD32 2960 (20080319) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com