Member
14
Points
|
Replied on
24 May 2013 12:46 PM IST
;With DupDel as
(Select row_number() over (partiton by column1,column2 order by column3 (must be primary key)) ID,column1,column2 from tbl_name)
Delete from DupDel where ID>1
|
Member
140
Points
|
Replied on
12 Dec 2013 10:34 AM IST
/* Delete Duplicate records */
WITH CTE (COl1,Col2, DuplicateCount)
AS
(
SELECT COl1,Col2,
ROW_NUMBER() OVER(PARTITION BY COl1,Col2 ORDER BY Col1) AS DuplicateCount
FROM DuplicateRcordTable
)
DELETE
FROM CTE
WHERE DuplicateCount > 1
GO
|