delete product group by name having count(*) > 1 |
2 answers
WITH CTE AS ( SELECT name, ROW_NUMBER() OVER(PARTITION BY name ORDER BY name) rnk FROM product ) DELETE FROM CTE WHERE rnk > 1; |
The first simplest thing that comes to mind is to write data to a temporary table with a distink, then delete and re-insert it. Not at all optimal, but if the plate is small it will work quickly.
select distinct name INTO #temp from product delete product group by name having count(*) > 1 insert into product select * from #temp drop table #temp |
testing- PashaPash ♦