|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
unique Key constraintHi! 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. -- Patrice "Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de news: 2E5B8DED-F202-48D6-B871-8D08CDBF1***@microsoft.com...Show quote > 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 Baren wrote:
> Hi! All, Use WITH NOCHECK option with your ALTER TABLE statement.> > 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. Sericinus hunter wrote:
> Baren wrote: Sorry, I misread. This will not work with unique constraint.>> 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 Show quote "Baren" <Ba***@discussions.microsoft.com> wrote in message news:2E5B8DED-F202-48D6-B871-8D08CDBF194A@microsoft.com... > 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 |
|||||||||||||||||||||||