PRB: Uniqueness of Index Violated When Creating Primary IndexLast reviewed: January 15, 1996Article ID: Q142283 |
The information in this article applies to:
SYMPTOMSAfter you create a Primary Index for a table that is populated with records and choose to make the structure changes permanent, the following error message appears:
Uniqueness of index <name> is violated. CAUSEMore than one record, including any deleted records, contain the same value within the field being used for the Primary Index. This also applies to the existence of more than one blank record, whether marked for deletion or not.
RESOLUTIONEliminate any use of the same value within multiple records. There are many methods you could use, but perhaps the easiest is to use a query. The following example query will generate a cursor that contains a list of the values that occur in more than one record of a table:
SELECT <field name> FROM <table name>; GROUP BY <field name>; HAVING COUNT(<field name>) > 1For information about obtaining the number of duplicate records, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q115617 TITLE : How to List Duplicate Records in a FieldFor information about deleting duplicate records, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q104332 TITLE : Methods of Deleting Duplicate Records from a DatabaseIf duplicate records have been marked for deletion and you prefer that the table not be packed to eliminate them, the Primary Index must contain the following filter to ignore the deleted records:
!DELETED()For more information about reusing deleted primary key values, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q139756 TITLE : Cannot Reuse Deleted Primary Key Values in Visual FoxPro STATUSThis behavior is by design.
MORE INFORMATIONThe intent of a primary index is to never permit duplicate values on the specified fields. For more information about primary indexes, search for "primary index" in the Visual FoxPro Help file.
Steps to Reproduce Behavior
|
Additional reference words: 3.00 3.00b VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |