In addition to the points in other answers, here are some key differences between the two.
Note: The error messages are from SQL Server 2012.
Errors
Violation of a unique constraint returns error 2627.
Msg 2627, Level 14, State 1, Line 1
Violation of UNIQUE KEY constraint 'P1U_pk'. Cannot insert duplicate key in object 'dbo.P1U'. The duplicate key value is (1).
The statement has been terminated.
Violation of a unique index returns error 2601.
Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object 'dbo.P1' with unique index 'P1_u'. The duplicate key value is (1).
The statement has been terminated.
Disabling
A unique constraint cannot be disabled.
Msg 11415, Level 16, State 1, Line 1
Object 'P1U_pk' cannot be disabled or enabled. This action applies only to foreign key and check constraints.
Msg 4916, Level 16, State 0, Line 1
Could not enable or disable the constraint. See previous errors.
But the unique index behind a primary key constraint or a unique constraint can be disabled, as can any unique index. Hat-tip Brain2000.
ALTER INDEX P1_u ON dbo.P1 DISABLE ;
Note the usual warning that disabling a clustered index makes the data inaccessible.
Options
Unique constraints support indexing options like FILLFACTOR
and IGNORE_DUP_KEY
, though this hasn't been the case for every versions of SQL Server.
Included Columns
Nonclustered indexes can include non-indexed columns (termed a covering index, this is a major performance enhancement). The indexes behind PRIMARY KEY and UNIQUE constraints cannot include columns. Hat-tip @ypercube.
Filtering
A Unique constraint cannot be filtered.
A unique index can be filtered.
CREATE UNIQUE NONCLUSTERED INDEX Students6_DrivesLicence_u
ON dbo.Students6( DriversLicenceNo ) WHERE DriversLicenceNo is not null ;
Foreign Key Constraints
A Foreign Key constraint cannot reference a filtered unique index, though it can reference a non-filtered unique index (I think this was added in SQL Server 2005).
Naming
When creating constraint, specifying a constraint name is optional (for all five types of constraints). If you don't specify a name then MSSQL will generate one for you.
CREATE TABLE dbo.T1 (
TID int not null PRIMARY KEY
) ;
GO
CREATE TABLE dbo.T2 (
TID int not null CONSTRAINT T2_pk PRIMARY KEY
) ;
When creating indexes, you must specify a name.
Hat-tip @i-one.
Links
http://technet.microsoft.com/en-us/library/aa224827(v=SQL.80).aspx
http://technet.microsoft.com/en-us/library/ms177456.aspx