Link to home
Start Free TrialLog in
Avatar of ateam
ateam

asked on

Can't create UNIQUE INDEX becuase of null

I try to create UNIQUE INDEX on sql server table but I get an error massge becuase of the null in my key.

I have 3000 records in my table and I want to add this Unique index to the row and ignore the the null.

here is my error massge:
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE UNIQUE INDEX terminated because a duplicate key was found for index ID 28. Most significant primary key is '<NULL>'.
SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dportas
dportas

In the interests of completeness I will also mention that SQL Server 2008 has a possible "workaround". It's possible to declare a filter on a unique index so that only some rows will be considered. I suggest you don't go there though.