Alan Lambert
2009-12-22 18:20:21 UTC
I'm using SQLCE 3.5
I have a table that is storing an order list with 2 fields ID and
Description. ID is sequentailly numbered.
I want to insert 2 extra items in the middle of the list (before item 5,
let's say) and run the following query:
UPDATE myTable
SET Id=Id+2
WHERE Id>=5
To move all items greater than 5 'up' 2 places so I can then insert the new
records. However, I get the following error message:
Major Error 0x80040E2F, Minor Error 25016
WHERE Id>=5
A duplicate value cannot be inserted into a unique index. [ Table name =
myTable,Constraint name = PK_myTable ]
I understand that it's trying to 'move' the items into already existing
places but why. When using SQL Server it batch processes and handles this
fine. Am I doing something wrong here or is there a way around this?
Many thanks
Alan
I have a table that is storing an order list with 2 fields ID and
Description. ID is sequentailly numbered.
I want to insert 2 extra items in the middle of the list (before item 5,
let's say) and run the following query:
UPDATE myTable
SET Id=Id+2
WHERE Id>=5
To move all items greater than 5 'up' 2 places so I can then insert the new
records. However, I get the following error message:
Major Error 0x80040E2F, Minor Error 25016
UPDATE myTable
SET Id=Id+2WHERE Id>=5
A duplicate value cannot be inserted into a unique index. [ Table name =
myTable,Constraint name = PK_myTable ]
I understand that it's trying to 'move' the items into already existing
places but why. When using SQL Server it batch processes and handles this
fine. Am I doing something wrong here or is there a way around this?
Many thanks
Alan