daglugub37
Technical User
I would like to alter a table and add a unique constraint to a combination of 3 columns. I know there are several records present that would violate this constraint. Can I ignore those present records and apply the constraint to be used for future inserts.
Here is what I tried.
ALTER TABLE tblX WITH NOCHECK
ADD CONSTRAINT uk_constraint_name
UNIQUE (colB, colC, colD)
It returned a "can not create unique index" error...due to duplicates.
So it would appear that for unique constraints you can NOT ignore duplicates..and that a unique index will be created auotmatically as well....kind of like a PK constraint.
Is this so?
Here is what I tried.
ALTER TABLE tblX WITH NOCHECK
ADD CONSTRAINT uk_constraint_name
UNIQUE (colB, colC, colD)
It returned a "can not create unique index" error...due to duplicates.
So it would appear that for unique constraints you can NOT ignore duplicates..and that a unique index will be created auotmatically as well....kind of like a PK constraint.
Is this so?