如何检测 SQL Server 表中的重复行? [英] How to detect duplicate rows in a SQL Server table?

查看:43
本文介绍了如何检测 SQL Server 表中的重复行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 10 列/50K 行的表中检测重复项的最有效方法是什么?我使用的是 MSSQL 8.0

What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0

推荐答案

举例说明其他人的描述:

To show an example of what others have been describing:

SELECT
    Col1, -- All of the columns you want to dedupe on
    Col2, -- which is not neccesarily all of the columns
    Col3, -- in the table
    Col4,
    Col5,
    Col6,
    Col7,
    Col8,
    Col9,
    Col10
FROM
    MyTable
GROUP BY
    Col1,
    Col2,
    Col3,
    Col4,
    Col5,
    Col6,
    Col7,
    Col8,
    Col9,
    Col10
HAVING
    COUNT(*) > 1

这篇关于如何检测 SQL Server 表中的重复行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆