I have a sample data where the ID is unique, but there are multiple duplicate rows(excluding ID). The other columns are Name, Age, DOB, Transaction Date, Payment, Amount. I have purposely duplicated few rows, and kept ID unique.
--Deleting Duplicate
;WITH Cte AS (SELECT ID,Name, Age, DOB, Transaction_Date, Payment, Amount, ROW_NUMBER() OVER(PARTITION BY Name, Age, DOB, Transaction_Date, Payment, Amount ORDER BY ID) Seq FROM #Temp) DELETE FROM Cte WHERE Seq<>1
Please Give Your Comments and Ask Some Questions:
No comments:
Post a Comment