SQL Server – Find Unique Index Without Unique Constraint

dmvsql serversql-server-2012sql-server-2016

I need to find list of unique indices that does not have unique constraint on that column. How to achieve this?

I know, following query will give me unique constraints.

SELECT * 
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS 
WHERE CONSTRAINT_TYPE='UNIQUE'

Note: I am using SQL Server 2012.

Best Answer

sys.indexes includes columns that identify if the index is unique, supports a unique constraint, or supports a primary key constraint. The query below lists unique indexes that do not support a constraint:

SELECT *
FROM sys.indexes
WHERE is_unique = 1 AND is_unique_constraint = 0 AND is_primary_key = 0;