I have a two-column primary key on a table. I have attempted to alter it to set the ignore_dup_key to on with this command:
ALTER INDEX PK_mypk on MyTable
SET (IGNORE_DUP_KEY = ON);
But I get this error:
Cannot use index option ignore_dup_key to alter index 'PK_mypk' as it enforces a primary or unique constraint.
How else should I set IGNORE_DUP_KEY to on?
It’s not documented in Books Online, but I’ve found that while
IGNORE_DUP_KEYis valid for Primary Keys, you can’t change it with an ALTER INDEX; you’ll have to drop and re-create the primary key.Keep in mind that
IGNORE_DUP_KEYdoesn’t allow you to actually store duplicate rows in a unique index, it simply changes how it fails when you try it:From http://msdn.microsoft.com/en-us/library/ms175132.aspx