|
jollyguy77
Starting Member
3 Posts |
Posted - 03/13/2013 : 12:22:08
|
Hi,
I have a table that has around 5000 records. I have a requirement that i want to change a varchar column to UNIQUE, but the problem is that there are many rows that has empty values in it. If i try to change the column to UNIQUE, i am getting an error that "The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name. The duplicate key value is ()". My requirement is that the Column should have a Unique values in select cases while adding a new rows, sometimes null values can also be present. Is there a way for me to create a UNIQUE for that column. If i create a Trigger will that work out? If so how.
Thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48064 Posts |
Posted - 03/13/2013 : 12:39:14
|
you can create unique constraint only after removing current duplicates
However, if you want constraint to be enforced only for newly added records, you can add constraint with NO CHECK option
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|