Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Remove duplicate records

Author  Topic 

deepakugale
Starting Member

33 Posts

Posted - 2010-02-17 : 00:48:14
Hi Experts,
What are different methods to remove duplicate entries from tables ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-17 : 00:59:21
http://www.databasejournal.com/features/mssql/article.php/1438651/Removing-Duplicate-Records.htm

also SQL 2005 methods like

DELETE t
FROM
(SELECT ROW_NUMBER() OVER(PARTITION BY <duplicate column set> ORDER BY PK) AS Seq
FROM Table
)t
WHERE Seq=1


DELETE t
FROM Table t
CROSS APPLY (SELECT TOP 1 PK
FROM Table
WHERE <duplicate column set>=t.<duplicate column set>
ORDER BY PK) t1
WHERE t1.PK<>t.PK


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -