Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Handle Duplicate Records

By Erik Andersen, 2009/01/07

The "Featured Script" a couple days ago was a simple way to delete duplicates. A common task if only because end-users will rarely check if some value already exists before entering it again. Wanted to offer a more complicated solution, comes in handy when you need to do more than just delete -- combine child records, keep a record of deletes, make a change to the record you're keeping, etc.

This solution uses embedded cursors, so is definitely a performance monster. On very large tables, with a large number of duplicates, you should run it during off-times.

[ListOfFields] below would be all the fields that have to match to be considered a duplicate.

 

Aside - my first posting on SQLServerCentral. I'm a long-time reader and big fan, dipping my foot in on posting. Maybe I'll move up to articles next time... :-) This is kinda fun.

Total article views: 1945 | Views in the last 30 days: 5
 
Related Articles
SCRIPT

Deleting Duplicate Records

In Datawarehousing, a normal scenario is eleminating duplicate records/rows or deleting duplicate re...

FORUM

Deleting Duplicate Record in Production

Deleting Duplicate Record in Production

SCRIPT

Deleting Duplicate Records

This article explains a simple solution for the common problem in MSSQL 7.0/2000, finding & deleting...

FORUM

Delete duplicate records in a table

Delete duplicate records in a table

FORUM

delete duplicates

delete duplicates

Tags
duplicate records    
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones