Msg 1979, Level 16, State 1, Line 2
Cannot use index option ignore_dup_key to alter index ‘%.*ls’ as it enforces a primary or unique constraint.
This error message appears when you try to alter an index to allow duplicate keys, but this index is used to enforce a PRIMARY KEY or UNIQUE constraint, which does not allow duplicates by definition.
The T-SQL statement can be parsed, but causes the error at runtime.
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be run this way. You can not alter an index that is used by SQL Server to enforce uniqueness to allow duplicates.
All versions of SQL Server.
IF OBJECT_ID(‘dbo.t’) IS NOT NULL
DROP TABLE dbo.t;
CREATE TABLE dbo.t
CONSTRAINT PK_t PRIMARY KEY NONCLUSTERED
ALTER INDEX PK_t ON dbo.t
(IGNORE_DUP_KEY = ON);
In the above example we try to alter the index PK_t to allow duplicate keys. Since this index is used to enforce a PRIMARY KEY constraint the error is raised.