Adding a UNIQUE constraint
From: Tom T. (T._at_discussions.microsoft.com)
Date: 06/14/04
- Next message: Adam Machanic: "Re: UNIQUE constraint problem"
- Previous message: RP: "Re: sql2k: ole db timeout"
- Next in thread: Tom Moreau: "Re: Adding a UNIQUE constraint"
- Reply: Tom Moreau: "Re: Adding a UNIQUE constraint"
- Reply: Gregory A. Larsen: "Re: Adding a UNIQUE constraint"
- Reply: Louis Davidson: "Re: Adding a UNIQUE constraint"
- Reply: Cowboy \(Gregory A. Beamer\) [MVP]: "Re: Adding a UNIQUE constraint"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Jun 2004 07:21:02 -0700
Hi all!
This is making me nuts.
Using SQL 2000, I am trying to add a UNIQUE constraint to an existing table (already populated with data). I have "scrubbed" the data so that the only repeated values are NULL. According to all the documentation I can find, UNIQUE constraints are allowed where the only duplicate value is NULL. However, every time I try to do this:
ALTER TABLE myTable
ADD CONSTRAINT u_SSN UNIQUE (SSN)
I get the following response:
Server: Msg 1505, Level 16, State 1, Line 1
CREATE UNIQUE INDEX terminated because a duplicate key was found for index ID 24. Most significant primary key is '<NULL>'.
Server: Msg 1750, Level 16, State 1, Line 1
Could not create constraint. See previous errors.
The statement has been terminated.
Am I missing something? Is there a way to add a UNIQUE constraint to an already existing table/column?
Thanks!
Tom
- Next message: Adam Machanic: "Re: UNIQUE constraint problem"
- Previous message: RP: "Re: sql2k: ole db timeout"
- Next in thread: Tom Moreau: "Re: Adding a UNIQUE constraint"
- Reply: Tom Moreau: "Re: Adding a UNIQUE constraint"
- Reply: Gregory A. Larsen: "Re: Adding a UNIQUE constraint"
- Reply: Louis Davidson: "Re: Adding a UNIQUE constraint"
- Reply: Cowboy \(Gregory A. Beamer\) [MVP]: "Re: Adding a UNIQUE constraint"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|