How to detect duplicate rows in a SQL Server table?

前端 未结 5 619
渐次进展
渐次进展 2021-02-02 07:03

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

5条回答
  •  悲哀的现实
    2021-02-02 07:22

    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
    

提交回复
热议问题