Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Unique Index

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-10 : 13:28:43
hug writes "The SQL Books online say
-------------------------------------------
Creating and Modifying UNIQUE Constraints
UNIQUE constraints can be:

Created when the table is created, as part of the table definition.
Added to an existing table, provided that the column or combination of columns comprising the UNIQUE constraint contain only unique or NULL values. A table can contain multiple UNIQUE constraints.
Modified or deleted if they already exist. For example, you may want the UNIQUE constraint of the table to reference other columns, or you may want to change the type of index clustering.
-------------------------------------------------
I have a table that already has lots of rows, If i try and alter the table and add a field with a unique constraint.

alter table atable
add email2 varchar(100)
constraint email2_chk unique

i get an error message
CREATE UNIQUE INDEX terminated because a duplicate key was found. Most significant primary key is ''.

what am i missing ?

thanks in advance"
   

- Advertisement -