Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How the rowid works in deleting duplicate records from table.
Posted

1 solution

DELETE
FROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)



http://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/

http://www.orafaq.com/faq/how_does_one_eliminate_duplicates_rows_from_a_table
 
Share this answer
 
Comments
Member 10431234 28-Nov-13 7:49am    
Thanks for reply:). one more question I have. What is the difference between max(id), min(id)
and when we use it?
[no name] 28-Nov-13 10:24am    
In checking of duplicate records: keeping Max id row with deleting of min ids.
And for min(id) keeping minimum Id row and deleting rest max id rows vice-versa
Ex..Row ID 1,2,3,4...
in min(id) case it will keep 1 and delete rest of rows.... like that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900