SQLServer 数据去重高效方法
2011-04-13 20:43 YZGJTSJT 阅读(4512) 评论(5) 编辑 收藏 举报数据去重高效方法
去重的方法有很多,比如用什么Distinct、 Group By Having、临时表等
有兴趣的朋友可以把各种方法对比一下得出直观的效率概况
WITH TEST AS
(
SELECT ROW_NUMBER()
OVER(PARTITION BY Column1,Column2,Column3 ORDER BY ID )
AS NUM,* FROM TableName
)
DELETE FROM TEST
WHERE NUM != 1
(
SELECT ROW_NUMBER()
OVER(PARTITION BY Column1,Column2,Column3 ORDER BY ID )
AS NUM,* FROM TableName
)
DELETE FROM TEST
WHERE NUM != 1
百万数据量一分左右(当然也要看机器配置)