查询数据库中具体表 所用到的索引 名称和 索引列

use TestDB

GO

SELECT indexname = a.name , tablename = c. name , indexcolumns = d .name , a .indid
FROM sysindexes a JOIN sysindexkeys b ON a .id = b .id AND a .indid = b.indid
JOIN sysobjects c ON b .id = c .id
JOIN syscolumns d ON b .id = d .id AND b .colid = d .colid
WHERE a .indid NOT IN ( 0 , 255 )
-- and c.xtype='U' and c.status>0 -- 查所有用户表
AND c .name = 'TestUser' --查指定表
ORDER BY c. name ,
a.name ,
d.name

posted @ 2015-08-28 21:09  天地盟主  阅读(1604)  评论(0编辑  收藏  举报