1

Cannot insert duplicate key row in object 'dbo.OCRD' with unique index 'OCRD_ABS_ENTRY'. The duplicate key value is (1). The statement has been terminated.;

An error occurred while updating the entries. See the inner exception for details.; An error occurred while updating the entries. See the inner exception for details.

Inner Exception: Cannot insert duplicate key row in object 'dbo.OCRD' with unique index 'OCRD_ABS_ENTRY'. The duplicate key value is (1). The statement has been terminated.

An error occurred while updating the entries. See the inner exception for details. An error occurred while updating the entries. See the inner exception for details.

It's an insert on DB

2
  • So your question is..? The error is literally telling you the problem here. Commented Aug 9, 2018 at 13:21
  • Look at the definition of the index OCRD_ABS_ENTRY. This will tell you which Field you are having a problem with. The error message is telling you that the value you are trying to insert is the value "1". A unique index will prevent duplicate values for that column from being inserted. So you will either need to a) change the value to something that is unique or b) change the index so that it doesn't have a unique constraint. 99% of the time the correct coarse of action will be a). Commented Aug 9, 2018 at 13:23

2 Answers 2

1
  • You have a column named "OCRD_ABS_ENTRY" which has an integrity constraint (unique key or primary key).
  • You try to insert another entry with value "1" for OCRD_ABS_ENTRY column, which should be unique.
  • Try to delete the constraint if it's not necessary, or to insert with another value.
Sign up to request clarification or add additional context in comments.

2 Comments

I don't have column named "OCRD_ABS_ENTRY" it's autogenerate from db...my PK is CardCode
Ok I have a primary key... row |primary_key| other columns 1 100001 ... 2 100002 ... 3 500000 ... I try to insert a new record with primary_key 100003 From what I understand is trying to write the new record in row 1 and I do not understand the reason ...
1

follow what @Florian already said. Additional information

  • insert values into tables with out mentioning value to primary field

7 Comments

Ok I have a primary key... row |primary_key| other columns 1 100001 ... 2 100002 ... 3 500000 ... I try to insert a new record with primary_key 100003 From what I understand is trying to write the new record in row 1 and I do not understand the reason ...
is your primary key auto incremented or not?
as you inserted 1 once so you are not allowed to again insert 1 in praimary key colum, duplicacy not allowed in primary key .it always will be unique
can u plz describe about your primary key and what is your dbms
Primary key is nvarchar dbms sql server
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.