Skip to Content

Duplicate rows indentified while creating an unique non-clustered index

Dear Experts,

When are trying to recreate an unique non-clustered index over a table, it got failed after 4+ hours with an error message "unique non-clustered index got failed due to duplicate rows identified". Can anyone please let me know the way to extract those duplicate rows from the table and also a solution to fix this issue?

Regards,

Dilip Voora

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 27, 2015 at 01:55 AM

    To find the sets of keys with duplicates,

    select <keys>, count(*) 

    from <tablename>
    group by <keys>
    having count(*) > 1

    You will then want to look at the full rows that have duplicate keys to decide how to handle them (perhaps by deleting some of the rows).

    Add comment
    10|10000 characters needed characters exceeded