Find duplicate in SQL and delete

A simple query for finding duplicates in a table. You can use this query to find duplicate values in one or more columns.
For single column
SELECT
    Field1, Count(*)
FROM TableName
Group By Field1
HAVING COUNT(*) > 1

Now delete rows with duplicate records
WHILE(EXISTS(SELECT MAX(ID)
    FROM TableName
    Group By Field1
    HAVING COUNT(*) > 1)
DELETE TableName
WHERE ID IN
(
    SELECT
        MAX(ID)
    FROM TableName
    Group By Field1
    HAVING COUNT(*) > 1
)

For duplicate in multiple columns (two or more)
SELECT
    Field1, Field2, Field3, Count(*)
FROM TableName
Group By Field1, Field2, Field3
HAVING COUNT(*) > 1

Now delete rows with duplicate records
WHILE(EXISTS(SELECT MAX(ID)
    FROM TableName
    Group By Field1, Field2, Field3
    HAVING COUNT(*) > 1)
DELETE TableName
WHERE ID IN
(
    SELECT
        MAX(ID)
    FROM TableName
    Group By Field1, Field2, Field3
    HAVING COUNT(*) > 1
)