0

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.

1
  • Hey go take a look at that green check mark down there on that (correct) answer Apr 6 at 1:38

1 Answer 1

3

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.