如何查询SQL Server 中 Index 的创建时间

今天有人问如何查询index的创建时间,使用下面的脚本可以查询出索引列已经创建时间:

select
    i.name as IndexName,
    o.name as TableName,
    ic.key_ordinal as ColumnOrder,
    ic.is_included_column as IsIncluded,
    co.[name] as ColumnName,
    o.create_date
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.[type] = 2
--and i.is_unique = 0
--and 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;

 

上一篇:Java面试题之多线程打印


下一篇:关于SQL视图的创建和使用方法