Try the below method:
create Table Test(Col1 int,Col2 int)
Insert into test Values
(1,1),(1,2),(1,3),(1,3),(1,4)
Select * From test
--First test the value as below
;with cte as
(Select *,Row_Number()over(partition by Col1,Col2 order by Col1,Col2 asc) Rn
From test
)Select * From cte where rn=1
--Actual delete after confirming your data
;with cte as
(Select *,Row_Number()over(partition by Col1,Col2 order by Col1,Col2 asc) Rn
From test
)Delete From cte where rn>1
Select * From test
Drop table test
No comments:
Post a Comment