Minggu, 18 Mei 2014

How To Remove Duplicate Rows in SQL Server

Following code is useful to delete duplicate records in SQL Server.

For Example : Table TABLE_NAME has three columns COL1, COL2 and COL3

Now you can use below script to delete duplicate records from table TABLE_NAME.

DELETE
FROM TABLE_NAME WHERE TABLE_NAME.%%physloc%% NOT IN (SELECT MIN(b.%%physloc%%) FROM TABLE_NAME b GROUP BY b.COL1, b.COL2,b.COL3);


Source:http://www.tutorialsdesk.com/2012/09/how-to-remove-duplicate-rows-in-sql.html

Tidak ada komentar:

Posting Komentar