I have duplicate rows in my table, how can I delete them based on a single column\'s value?
Eg
uniqueid, col2, col3 ...
1, john, simpson
2, sally, ro
You have many ways for deleting the duplicate records some of them are below...........
Different ways to delete Duplicate records
Using Row_Number() function and CTE
with CTE(DuplicateCount) as ( SELECT ROW_NUMBER() OVER
(PARTITION by UniqueId order by UniqueId ) as DuplicateCount from
Table1 ) Delete from CTE where DuplicateCount > 1
.Without using CTE*
Delete DuplicateCount from ( Select Row_Number() over(Partition by
UniqueId order by UniqueId) as Dup from Table1 ) DuplicateCount
where DuplicateCount.Dup > 1
.Without using row_Number() and CTE
Delete from Subject where RowId not in(select Min(RowId ) from
Subject group by UniqueId)