Sql-server – how to check the last time dbreindex or an index defrag was executed

sql serversql-server-2008

Is there a quick tsql I can use to check when was the last time a dbreindex, index defrag and update stats was executed on the database?

Appreciate everyone's quick response.

Best Answer

Try one of the queries below and see if that is what you are looking for:

SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_system_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'YourDb')
AND OBJECT_ID=OBJECT_ID('YourTable')


select name as index_name,
         stats_date( object_id, index_id) as stats_update_date
from  sys.indexes
where object_id = object_id('YourTable');


Select * 

From sys.dm_db_index_usage_stats