Cannot insert duplicate key row in object with index ncix_id with non-unique index
Oleksii Filipov
20
Reputation points
Hello!
Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) on Linux (CentOS Linux 7 (Core)) <X64>
We have a table with 3 indexes:
- FIX_ActionSerial - nonclustered, unique located on PRIMARY - ActionSerial
- ncix_planID - nonclustered located on PRIMARY - PlanId
- PK_CampaignSummary - clustered, ignore duplicate keys, unique, primary key located on PRIMARY - MonthId, WeekId, ActionSerial, LifecycleStageId, KpiId
Index number 2 was created recently and immediately after that we started to get an error message:
Cannot write data to SQL
Cannot insert duplicate key row in object 'mpe.CampaignSummary'
with unique index 'ncix_planID'.
The duplicate key value is (794, 94, 404, 39318, 0, 1).\n
The statement has been terminated
Those values from the error message are PlanId from nonclustered non-unique index + all columns from PK. It is completed on a rerun.
Does anybody has an idea:
- Why we have ncix_PlanID index in an error message saying it is UNIQUE? (yes I know we still have every index unique behind the scene)
- Why we see values like that - yes I know nonclustered index contains clustered key but it should be behind the scene, isn't it?
I would appreciate any thoughts.
P.S. We do not have indexed views on a table.
Thanks!
SQL Server Other
14,494 questions
Sign in to answer