Get the unique constraint columns list (in TSQL)?

前端 未结 6 1720
日久生厌
日久生厌 2021-02-01 01:56

I can get a list of unique constraints fairly easily with the following query:

select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where CONSTRAINT_TYPE=\'UNIQUE\         


        
6条回答
  •  生来不讨喜
    2021-02-01 02:37

    SELECT *
    FROM    sys.indexes i
            JOIN sys.index_columns ic
                ON i.index_id = ic.index_id
                   AND i.object_id = ic.object_id
    WHERE i.is_unique_constraint = 1;
    

提交回复
热议问题