Remove duplicate records from table
-
2012年5月2日 18:45
Hi,
I Found duplicate records in the table and want to remove; on the following query i found duplicate records;
SELECT * FROM [rFAR_Aggregated_Fallout4ManualRecon] where [rFAR_AggregationID] in ( SELECT [rFAR_AggregationID] FROM [rFAR_Aggregated_Fallout4ManualRecon] group by [rFAR_AggregationID] having count([rFAR_AggregationID])>1 ) order by rFAR_AggregationID
全部回复
-
2012年5月2日 18:50版主
Try:
;with cte as (select *, row_number() over (partition by [rFAR_AggregationID] order by DateField) as Rn FROM [rFAR_Aggregated_Fallout4ManualRecon]) delete from cte where Rn > 1
For every expert, there is an equal and opposite expert. - Becker's Law
My blog- 已标记为答案 Kashif Chotu 2012年5月2日 19:06
-
2012年5月2日 19:06Thanks. Work Fine.
-
2012年5月2日 19:11
WITH RemoveDuplicate AS ( SELECT *, ROW_NUMBER() OVER(PARTITION BY empid, name ORDER BY empid,name) AS row FROM temp ) DELETE RemoveDuplicate WHERE row>1
- 已编辑 Nagendra Nandigam 2012年5月2日 19:13

