Delete duplicate records from Table using SQL

Category: SQL Comments: No comments

DeuplicateTable

1     ABC   10

1     ABC   10

1     ABC   10

1     ABC   10

1     ABC   10

2     XYZ   12

2     XYZ   12

2     XYZ   12

2     XYZ   12

2     XYZ   12

 

;WITH OrderedResults AS

(

SELECT ROW_NUMBER() OVER(PARTITION BY SRNO,NAME,CLASS ORDER BY SRNO) AS ROWNUMBER, * FROM #TEMP_TABLE2

)

DELETE OrderedResults WHERE ROWNUMBER<>1

 

 

OUT PUT:-

1     ABC   10

2     XYZ   12

Leave a Reply

Your email address will not be published. Required fields are marked *

*

HTML tags are not allowed.