1 --方案一 2 SELECT 索引名称=a.name 3 ,表名=c.name 4 ,索引字段名=d.name 5 ,索引字段位置=d.colid 6 FROM sysindexes a 7 JOIN sysindexkeys b ON a.id=b.id AND a.indid=b.indid 8 JOIN sysobjects c ON b.id=c.id 9 JOIN syscolumns d ON b.id=d.id AND b.colid=d.colid 10 WHERE a.indid NOT IN(0,255) 11 AND c.name='tableName' --你的表名称 12 ORDER BY c.name,a.name,d.name ASC 13 14 --方案二 15 WITH tbl 16 AS ( 17 SELECT A.index_id, A.object_id, B.name 18 FROM sys.index_columns A 19 INNER JOIN sys.columns B ON A.column_id=B.column_id AND A.object_id=B.object_id 20 ) 21 22 SELECT A.name AS TableName, B.name AS IndexName, B.rows, C.columnname AS ColumnName 23 FROM sys.tables AS A 24 INNER JOIN sysindexes B ON A.object_id=B.id 25 INNER JOIN ( 26 SELECT index_id, object_id, ( 27 SELECT name+',' 28 FROM tbl 29 WHERE tbl.index_id=A.index_id AND tbl.object_id=A.object_id 30 FOR XML PATH('') 31 ) AS columnname 32 FROM tbl A 33 GROUP BY index_id, object_id 34 ) C ON A.object_id=C.object_id AND B.indid=C.index_id 35 WHERE B.groupid=1 36 --查询某个表的索引 37 AND A.name='表名称' 38 --包含某个字段名 39 and C.columnname like '%字段名%' 40 ORDER BY B.rows DESC,A.name,b.name,b.indid ASC