Friday, February 29, 2008

Remove duplicate records (using a self join)!

Delete from MyTable where IdentCol not in
(
Select * from MyTable A where 1 >
( Select Count(*) from MyTable B where A.Name = B.Name and A.
IdentCol > B.IdentCol )
)

Note: The table should have an identity column or some column with unique integers.

No comments: