Error 1508

Severity

14

Message text

Create index aborted on duplicate rows. Primary key is 'S_KEY'.

Explanation

This error occurs when you try to create a clustered index on a table that contains duplicate rows.

Action

Decide whether you want to allow or prevent duplicate rows in the table where the clustered index will be created. Use one of the following procedures.


Allowing duplicate rows

Create the index with the allow_dup_row option:

1> create clustered index <index_name> on <table_name> 
2> with allow_dup_row
3> go

Subsequent update and insert commands can create duplicate rows after the allow_dup_row option is set.


Preventing duplicate rows

Create the index with the ignore_dup_row option:

1> create clustered index <index_name> on <table_name> 
2> with ignore_dup_row
3> go

Existing duplicate rows will be deleted from the table as the index is created. Subsequent attempts to enter a duplicate row with insert or update are ignored and the insert or update is cancelled with an informational message. If the insert or update is part of a larger transaction, the rest of the transaction will continue as usual.

Noteignore_dup_row and allow_dup_row are mutually exclusive. Using them together in the same create index statement causes error 1916 .

Versions in which this error is raised

All versions