Suppose we have a table "Users" with columns Id, UserName and the table contains some duplicate rows.
How to remove only the duplicate rows from the above table.
Below is the Solution:
How to remove only the duplicate rows from the above table.
Below is the Solution:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH CTE | |
AS | |
( | |
SELECT ROW_NUMBER() OVER (PARTITION BY UserName ORDER BY Id) AS rowNum, | |
Id,UserName FROM Users) | |
DELETE FROM CTE WHERE rowNum > 1 |