Thursday, May 24, 2012

Recently Used Tables and Databases

Recently developed these queries to assist with the evaluation of development or sandbox environments.  Sometimes disk space demands that old projects be cleared out, and managers/admins want to know what has and hasn't been used recently.

These queries are built around the dm_db_index_usage_stats DMV and use the last_user_scan, last_user_seek, and last_user_update dates to determine the databases and tables that have actually been used recently.  This is done at the index level.