使用 SQL Server Management Studio 2017。我导入了大约 2000 万封电子邮件的列表,只需运行以下代码即可删除所有重复项:
WITH CTE AS
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY email ORDER BY email) AS RN
FROM dbo.cleanemails
)
DELETE FROM CTE WHERE RN<>1
它说 Query 执行成功,在 Messages 选项卡下显示 1000 万行受影响(预期),但没有 Results 选项卡。我想导出到 csv 文件。我检查了执行设置,因为 Parseonly 和 Noexec 设置有时会导致问题,但它们都处于关闭状态。