Skip Navigation LinksHome > Categories > Code from a Category

Differences between UNIQUE Constraint and Index

User Name: codelecturer
Name: Mike Chauhan
Contact Me:
Home Page:
6 years of total IT experience including programming, application development, System Maintenance . 3 years of Experienced and expertise in .Net Framework VB, Visual Basic.Net, ASP.Net 2.0, 3.5 and AD... [More]
Viewed Times: 1430
Add Date: 01/27/2013
In this article we will learn about Difference between Unique Constraint and Index.
The differences between UNIQUE constraint and index are quite subtle since UNIQUE constraint in SQL Server is implemented as UNIQUE index.

UNIQUE constraint is a database object. UNIQUE index is not a database object. UNIQUE constraint creates a UNIQUE (candidate) KEY which can be used for Foreign Key referencing according to ANSI SQL rules.

T-SQL allows FK referencing to UNIQUE index columns also, however, this is not an ANSI feature.

The usage syntax is different. For example, index cannot be created in CREATE TABLE. Differences vis-a-vis table variables as demonstrated following.

Related system commands are different:

Happy Programming!!!

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.