Using a CTE to delete duplicates
Some of my other posts show how to find and delete duplicate records from SQL Server. This is another way to delete duplicate records using a CTE.
A Common Table Expression (CTE) is a named result set in a SQL query. CTEs help keep your code organized and allow you to perform multi-level aggregations on your data, like finding the average of a set of counts.
WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3
ORDER BY ( SELECT 0)) RN
FROM #MyTable)
DELETE FROM cte
WHERE RN > 1;