------解决方案-------------------- 在MS SQL删除重复行的几种方法
------解决方案-------------------- 你用的 SQL Server 版本是什么样的?如果是 SQL 2008+,可以用分析函数:
SQL code
DELETE FROM table_1
WHERE id IN (
SELECT id
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY val ORDER BY id) AS serid,
id,
val
FROM TABLE_1
) a
WHERE serid > 1)