DEV Community

loading...

Answer: How can I remove duplicate rows?

boyukbas profile image baris ・1 min read

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

Discussion (0)

pic
Editor guide