DEV Community

baris
baris

Posted on

Answer: How can I remove duplicate rows?

Another possible way of doing this is

; 

--Ensure that any immediately preceding statement is terminated with a semicolon above
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;

I am using ORDER

</p>
Enter fullscreen mode Exit fullscreen mode





Smart answer 2

Top comments (0)