2010/01/23

【SQL Server】インデックスの一覧を抽出するSQL


SELECT
    i.name AS index_name
    ,o.name AS table_name
    ,col.name AS column_name
FROM
    sysindexkeys ik
    ,sysobjects o
    ,syscolumns col
    ,sysindexes i
WHERE
        ik.id = o.id
    AND ik.id = col.id
    AND ik.colid = col.colid
    AND ik.id = i.id
    AND ik.indid = i.indid
    AND o.xtype = 'U'
ORDER BY
    i.name
    ,ik.id
    ,ik.indid
    ,ik.keyno
 

2 件のコメント: