Hi
How to remove duplicate records from a table ?
How to Remove Duplicate Records from a Table
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anil KumarRank #367 · 6.8K reputationPosted Jul 4, 2012, 8:57 AM EDT
Removing Duplicates from a Table in SQL Server
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 4, 2012, 11:06 AM EDT
STEP 1 - Insert your distinct data into a temporary table select distinct* into temp from TableName
STEP 2 - Delete From TableName
STEP 3 - Insert TableName Select * From temp Write three step and remove duplicate values from your tables.
Thanks
Shen Hengbin94 reputationPosted Jul 4, 2012, 5:35 PM EDT
ID NAME
1 name1
2 name2
3 name1
4 name2
And you want to get rid of the duplicate data
you can try this.
BEGIN TRAN
DELETE
FROM
WHERE EXISTS(
SELECT * FROM
WHERE
T1.NAME = T2.NAME AND
T2.ID > T1.ID
)
SELECT * FROM
ROLLBACK
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 4, 2012, 7:50 PM EDT
There are many ideas to remove duplicate record from table
Idea 1:
http://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/
Idea 2:
http://support.microsoft.com/kb/139444
Idea 3:
http://www.codeproject.com/Tips/159881/How-to-remove-duplicate-rows-in-SQL-Server-2008-wh
hope this will help you.