Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Data Corruption Issues
 Duplicate Key Row
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

8 Posts

Posted - 12/22/2011 :  02:35:12  Show Profile  Reply with Quote

I'm getting the following error:

Error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert duplicate key row in object 'dbo.tblAccLocDetail' with unique index 'idx1'.(-2147217900)

What I did to try and resolve this was copy the data in this table to excel and then tried grouping it to see if I could spot any strange data (also used filters) as this was how I managed to fix it the last time. Problem is that this takes forever as I do it remotely and searching for it manually is horrible, does anyone know how I can resolve this with a more "productive" solution? Any tools out there that I could try?

Your help will be greatly appreciated.


Very Important crosS Applying yaK Herder

52326 Posts

Posted - 12/22/2011 :  04:14:20  Show Profile  Reply with Quote
how are you inserting values? is it by passing values directly or from another table?

SQL Server MVP

Go to Top of Page

Starting Member

8 Posts

Posted - 12/22/2011 :  04:50:31  Show Profile  Reply with Quote
During synchronisation. It inserts from another table, basically from one programs DB to the other.
Go to Top of Page

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/22/2011 :  07:25:06  Show Profile  Reply with Quote
First, look at the DDL of the index on the target table to see the columns that are in the unique index idx1.

Then, run the following query on the source table (assuming col1, col2, col3 are the columns in the unique index) to see the duplicate rows.

group by
  count(*) > 1
This will tell you the combinations of col1, col2, col3 that are not unique.

At this point, what you want to do depends on your business requirements. For example you may choose to insert only one row from each of the duplicate sets or you may choose to remove the unique constraint on the target table etc.
Go to Top of Page

Sana seofirst
Starting Member

2 Posts

Posted - 02/16/2012 :  02:21:43  Show Profile  Reply with Quote
Please tell me how find out all employee IDs whose birthday fall today ?
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000