unique Key constraint

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi! All,

I don't know whether this question fits into this forum or not> I just need
some help in regards to the below question.

I want to insert a unique key constraint on a column in an already existing
table which happens to have duplicate entries so that it doesn't check the
already existing entries but checks the new entry.

Thanks in advance for the help

Regards,
Baren
 
Can't you get rid of these duplicates once for all ? You may want to
elaborate a bit about your exact scenario.
 
Baren said:
Hi! All,

I don't know whether this question fits into this forum or not> I just need
some help in regards to the below question.

I want to insert a unique key constraint on a column in an already existing
table which happens to have duplicate entries so that it doesn't check the
already existing entries but checks the new entry.

Use WITH NOCHECK option with your ALTER TABLE statement.
 
If the column already contains duplicate records there's no way you can
create an unique key constraint on that column. You should first find all
the duplicate records having same column value for which you want to create
unique constraint. Then modify those column values to an unique value. Only
after that you can add the unique constraint.

Regards
Sanjib
 
Back
Top