11 February,2013 by Jack Vamvas
Question: Is there a difference between a UNIQUE CONSTRAINT versus UNIQUE INDEX?
Answer: Creating a UNIQUE CONSTRAINT automatically creates a UNIQUE INDEX. This makes a UNIQUE CONSTRAINT and UNIQUE INDEX similar.
The query optimizer interprets an explicitly created UNIQUE INDEX or a CONSTRAINT created index as the same.
Data is validated in the same way and both check for unique data
Deciding when to implement a UNIQUE CONSTRAINT versus a UNIQUE INDEX is an issue of design. A UNIQUE CONSTRAINT is part of the database design logical view. A UNIQUE INDEX is part of the database design physical view
--how to create a unique constraint ALTER TABLE myTable ADD CONSTRAINT myConstraint UNIQUE NONCLUSTERED ( A_col ) --how to create a unique index CREATE UNIQUE INDEX uix_my_unique_index ON myTable(a_col)