2020-07-27

表包含全部索引的索引结构

DECLARE @tbl nvarchar(265)SELECT @tbl = '' SELECT o.name,i.index_id, i.name, i.type_desc,  substring(ikey.cols, 3, len(ikey.cols))AS key_cols,  substring(inc.cols, 3, len(inc.cols)) ASincluded_cols,  stats_date(o.object_id, i.index_id) ASstats_date,  i.filter_definitionFROM sys.objects oJOIN sys.indexes i ON i.object_id = o.object_idCROSS APPLY (SELECT ', ' + c.name +      CASE ic.is_descending_key       WHEN 1 THEN ' DESC'       ELSE ''      END    FROM sys.index_columns ic    JOIN sys.columns c ON ic.object_id = c.object_id         AND ic.column_id = c.column_id    WHERE ic.object_id = i.object_id    AND ic.index_id = i.index_id    AND ic.is_included_column = 0    ORDER BY ic.key_ordinal    FOR '')) AS ikey(cols)OUTER APPLY (SELECT ', ' + c.name    FROM sys.index_columns ic    JOIN sys.columns c ON ic.object_id = c.object_id         AND ic.column_id = c.column_id    WHERE ic.object_id = i.object_id    AND ic.index_id = i.index_id    AND ic.is_included_column = 1    ORDER BY ic.index_column_id    FOR '')) AS inc(cols)WHERE o.name = @tbl AND i.type IN (1, 2)ORDER BY o.name, i.index_id

 

表包含全部索引的索引结构盘古集团俄罗斯灰色清关贝恩资本Zulily亚马逊"败走"中国,保留业务能否东山再起?Amazon Influencer Program十大羊肉美食胜地 冬日旅行温暖秘笈_北京市旅游旅行达人必备六件宝 可在任何时候帮助你内蒙古黑城:抛锚于历史长河的孤舟

No comments:

Post a Comment