By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,378 Members | 1,453 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,378 IT Pros & Developers. It's quick & easy.

Duplicate key ignored AND statement terminated

P: n/a

I have a table with a unique non-clustered index on it. It has the
IGNORE_DUP_KEY option on.

For some reason, I am getting the following error:

-----------------------------------------------------------------------------
System.Data.SqlClient.SqlException: Cannot insert duplicate key row in
object 'dbo.table1 with unique index 'IX_table1'.

Duplicate key was ignored.

The statement has been terminated.
------------------------------------------------------------------------------
It says the duplicate key was ignored, yet the statement is still
terminated

Is this data related?

Other databases in the instance are working fine, and this one was
doing okay, too.

We're running SQL Server 2005 SP2 with rollup 3; 64-bit; clustered;

thanks for any insight . . . .

traceable
Mar 20 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
traceable1 (th******@gmail.com) writes:
I have a table with a unique non-clustered index on it. It has the
IGNORE_DUP_KEY option on.

For some reason, I am getting the following error:

--------------------------------------------------------------------------
System.Data.SqlClient.SqlException: Cannot insert duplicate key row in
object 'dbo.table1 with unique index 'IX_table1'.

Duplicate key was ignored.

The statement has been terminated.
--------------------------------------------------------------------------

It says the duplicate key was ignored, yet the statement is still
terminated

Is this data related?
It would certainly help to see the table definition, including indexes.
Even better the statement that gives this effect.

Without that, the field is open to speculation. For instance, maybe you
submit a batch which first inserts into the table with the IGNORE_DUP_KEY
propery set and the duplicate key is ignored, but then the next statment
violates a unique index which does not have IGNORE_DUP_KEY set.

So the only advice I can give is to first double-check that the error
is on an index with IGNORE_DUP_KEY. Next track down the INSERT statement
and find the data that gives this error.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 20 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.