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

Yet Another Deleting Duplicate Records (in-place)

By Peter Petrov, 2009/01/15

Here is another "deleting duplicate records" script, this time in-place. It exploits the ability to relatively easily add and drop a uniqueidentifier column to a table. The term "must-be-unique columns" refers to the set of columns that have to have a unique combination of values (natural primary key candidate for the table). The DELETE statement is quite generic and the comments suggest the changes needed for any other table. In addition, you obviously have to replace "MyTab" with the name of your table.

Note: The "DELETE" statement is designed and formatted in order to extend its usage - replacing "DELETE t" with "SELECT t.*" will return the records that will be deleted.

Total article views: 1818 | Views in the last 30 days: 3
 
Related Articles
FORUM

delete table

delete

FORUM

Delete Duplicates from table with no identity column

delete duplicates from table with all columns with datatype varchar()

FORUM

How to delete first couple of rows without knowing column name

delete first 10rows from the table without knowing column names

FORUM

Deletion

Deletion of records

BLOG

Adding , Deleting and Updating a Column in a table

Many times we need to alter the table definition by adding , deleting or updating a column in the ta...

Tags
miscellaneous    
sql server 2005    
sql server 7    
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