SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

Slive
Starting Member

8 Posts

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

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.

Thanks,
Rogan.

visakh16
Very Important crosS Applying yaK Herder

India
52323 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
http://visakhm.blogspot.com/

Go to Top of Page

Slive
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

sunitabeck
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.

select
  col1,col2,col3
from
  SourceTable
group by
  col1,col2,col3
having
  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

India
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 ?
unspammed
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.08 seconds. Powered By: Snitz Forums 2000