1

When attempting to create an unique index with the following syntax:

CREATE UNIQUE INDEX Table_Index ON Table (CharColumn, IntColumn)

Why do I receive the error:

indexed columns are not unique

3
  • Someone else had the same problem, but their question was unanswered: mail-archive.com/[email protected]/msg68695.html Commented Dec 13, 2013 at 21:30
  • 1
    It's telling you why -- because the columns that you are trying to make into a UNIQUE INDEX are not unique. Commented Dec 13, 2013 at 21:32
  • It's a pretty lousy error message. It really means that there are some repeated values for that column. Commented Dec 16, 2013 at 14:35

2 Answers 2

3

You get the error "indexed columns are not unique" because the indexed columns are not unique, that is, there are some duplicate records.

Use a query like this to find out which records:

SELECT CharColumn,
       IntColumn,
       COUNT(*) AS Count
FROM MyTable
GROUP BY CharColumn,
         IntColumn
HAVING Count > 1
Sign up to request clarification or add additional context in comments.

Comments

0

If your table have already containing rows, then probably you have a 2 or more rows with the same values indicated in your tables unique index (CharColumn, IntColumn)

e.g. row CharColumn IntColumn 10 ABC 1 21 ABC 1

A unique index means no more than 1 rows should contains the value.

Comments

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.