This script will tell you for each database when it was last read from and written to.
select
db_name(database_id)
, LastRead = max(
case
when last_user_seek > last_user_scan and last_user_seek > last_user_lookup then last_user_seek
when last_user_scan > last_user_seek AND last_user_scan > last_user_lookup then last_user_scan
else last_user_lookup
end
)
, LastWrite = max(last_user_update)
from
(
select
database_id,
last_user_seek = coalesce(last_user_seek, '19000101'),
last_user_scan = coalesce(last_user_scan, '19000101'),
last_user_lookup = coalesce(last_user_lookup, '19000101'),
last_user_update = coalesce(last_user_update, '19000101')
from sys.dm_db_index_usage_stats
) x
group by
db_name(database_id)
order by
1;
No comments:
Post a Comment