Problem with updating multiple rows which are in conflict with unique index
Posted
by GUZ
on Stack Overflow
See other posts from Stack Overflow
or by GUZ
Published on 2010-04-07T14:22:52Z
Indexed on
2010/04/07
20:23 UTC
Read the original article
Hit count: 244
I am using Microsoft SQL Server and I have a master-detail scenario where I need to store the order of details. So in the Detail table I have ID, MasterID, Position and some other columns. There is also a unique index on MasterID and Position. It works OK except one case: when I have some existing details and I change their order. For example when I change a detail on position 3 with a detail on position 2. When I save the detail on position 2 (which in the database has Position equal to 3) SQL Server protests, because the index uniqueness constraint.
How to solve this problem in a reasonable way?
Thank you in advance
Lukasz Glaz
© Stack Overflow or respective owner