unique Key constraint

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
 
P

Patrice

Can't you get rid of these duplicates once for all ? You may want to
elaborate a bit about your exact scenario.
 
S

Sericinus hunter

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.
 
S

Sanjib Biswas

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top