Basically, in SQL Server, a unique constraint is actually implemented using a unique index.
The differences between the UNIQUE constraint and the UNIQUE INDEX are actually quite subtle. If you create a UNIQUE INDEX, you can refer to it in foreign key constraints from another table (does not work if you create a UNIQUE constraint ....).
And what's the difference? Good - a unique constraint is indeed more logical for a table - you want to express the intention that the contents of a given column (or group of columns) be unique.
A unique index (like most indexes) provides more detailed information about the behind-the-scenes implementation.
From my point of view, if you really have problems with this, I will always use UNIQUE INDEX - the advantage of partial restriction of referential integrity is quite acceptable and can be very useful in some cases. Functionally, in practice, there is no difference between using a unique constraint and a unique index.
marc_s Dec 16 '08 at 21:39 2008-12-16 21:39
source share