-
-
Save NaserKhoshfetrat/61c251f1cb5e186248acc9a2519ef91f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- list indexes | |
-- http://stackoverflow.com/a/428235/10245 | |
-- https://gist.github.com/timabell/6da05a2b2542c907f179 | |
select | |
o.name as TableName, | |
i.name as IndexName, | |
i.type, | |
i.is_unique, | |
ic.key_ordinal as ColumnOrder, | |
ic.is_included_column as IsIncluded, | |
co.[name] as ColumnName | |
from sys.indexes i | |
join sys.objects o on i.object_id = o.object_id | |
join sys.index_columns ic on ic.object_id = i.object_id | |
and ic.index_id = i.index_id | |
join sys.columns co on co.object_id = i.object_id | |
and co.column_id = ic.column_id | |
where | |
i.is_primary_key = 0 | |
and o.[type] = 'U' | |
--and ic.is_included_column = 0 | |
order by o.[name], i.[name], ic.is_included_column, ic.key_ordinal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment