remove duplicate rows | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

remove duplicate rows

A collegue of mine copied a db over without any of the constraints. Before he added the constraints, he started using the db. This allowed duplicate rows to be entered. He has since realized his mistake, and was wondering if there is an easy way to remove all the duplicate rows. Thanks for your help, Ben
Use:
SELECT DISTINCT *
INTO duplicate_table
FROM original_table
GROUP BY key_value
HAVING COUNT(key_value) > 1 DELETE original_table
WHERE key_value
IN (SELECT key_value
FROM duplicate_table) INSERT original_table
SELECT *
FROM duplicate_table DROP TABLE duplicate_table or this KBAhttp://support.microsoft.com/default.aspx?scid=kb;en-us;139444 to help with. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
if you want to remove duplicate records with ntext,text and image datatype .please do the below link stap.
http://www.codegroups.com/blog/inde…rom-table-with-text-ntext-or-image-data-type/
I hope this is help !
Regards,
Shaileshk

]]>