Méthode 1 :
with
cte as
(
select
row_number()over (partition by ParentProductCategoryID,Name order by ParentProductCategoryID ) as classement,
ParentProductCategoryID,Name
from [SalesLT].[ProductCategory]
where ParentProductCategoryID is not
null
)
delete
from cte where classement >1
Méthode 2 :
delete
from SalesLT.ProductCategory
where ParentProductCategoryID
in
(select ParentProductCategoryID from SalesLT.ProductCategory group by ParentProductCategoryID
having
count(*) >1