Malekbenz

Hi, I'm MalekBenz. I author this blog, I'm FullStack Developer, create courses & love learning, writing, teaching technology. ( Javascript, C#, ASP.NET , NodeJS, SQL Server )

Sql server how to remove a duplicated rows

Remove a duplicated rows ?

This how to remove a duplicated rows, using ROW_NUMBER() :

CMD

WITH TempTable (ID,rowNumber)
AS
(
	SELECT ID,ROW_NUMBER() OVER(PARTITION by ID ORDER BY ID) 
	AS rowNumber
	FROM CASNOS 
)
--Then delete all Duplicate Rows

DELETE FROM TempTable
WHERE rowNumber > 1 


That’s it & see you soon!.

Comments