-In the Optimization query SQL statement, view the Index usage SQL statement:
Select Db_name (database_id) as N ' database name ',
object_name (a.object_id) as N ' table name ',
B.name N ' index name ',
User_seeks N ' user index lookup times ',
User_scans N ' user index Scan count ',
Last_user_seek N ' Last Find time ',
Last_user_scan N ' Last scan time ',
Rows as N ' table number of lines '
From Sys.dm_db_index_usage_stats a Join
Sys.indexes b
On a.index_id = b.index_id
and a.object_id = b.object_id
Join sysindexes C
On c.id = b.object_id
where database_id=db_id (' database name ')--Specify Database
and object_name (a.object_id) Not like ' sys% '
and object_name (a.object_id) Like ' table name '--Specify Index Table
and b.name like ' index name '--Specify the index name to use sp_help ' your table name ' to see the structure of the table and all the index information
Order by User_seeks,user_scans,object_name (a.object_id)
-In the Optimization query SQL statement, view the Index usage SQL statement:
Select Db_name (database_id) as N ' database name ',
object_name (a.object_id) as N ' table name ',
B.name N ' index name ',
User_seeks N ' user index lookup times ',
User_scans N ' user index Scan count ',
Last_user_seek N ' Last Find time ',
Last_user_scan N ' Last scan time ',
Rows as N ' table number of lines '
From Sys.dm_db_index_usage_stats a Join
Sys.indexes b
On a.index_id = b.index_id
and a.object_id = b.object_id
Join sysindexes C
On c.id = b.object_id
where database_id=db_id (' database name ')--Specify Database
and object_name (a.object_id) Not like ' sys% '
and object_name (a.object_id) Like ' table name '--Specify Index Table
and b.name like ' index name '--Specify the index name to use sp_help ' your table name ' to see the structure of the table and all the index information
Order by User_seeks,user_scans,object_name (a.object_id)
"/>
Usage of SQL Server indexes