Tuesday, February 2, 2016

All indexes which haven’t been used yet


 ---All indexes which haven’t been used yet can be retrieved with the following statement:

select object_name(object_id), i.name
from sys.indexes i
where  i.index_id NOT IN (select s.index_id
from sys.dm_db_index_usage_stats s
where s.object_id=i.object_id and
i.index_id=s.index_id and
database_id =  DB_id(db_name()))
order by object_name(object_id) asc

No comments:

Post a Comment