Comment supprimer les lignes en double d’une table SQL Server ?

0
701

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 :

deletefrom SalesLT.ProductCategory
   where ParentProductCategoryID in
   (select ParentProductCategoryID from SalesLT.ProductCategory  group by ParentProductCategoryID
    having
    count(*) >1

LEAVE A REPLY

Please enter your comment!
Please enter your name here