SQL Script to find database last access date
Sometime we create databases on Test/ Development database servers for temporary uses for short duration and forgot to delete them after the work got completed. As a part of house keeping activity, we need to find out when a database is last accessed in order to find out the databases which are not used since long time and can be a deleted.
Below mentioned SQL query will going to help you in finding out the last access date of all the databases of a SQL server
SELECT name as [Database Name], [Last Access Date] =(select MAX(temp.lastaccess)
from ( select lastaccess =
max(last_user_seek)
where max(last_user_seek)is not null
union all
select lastaccess = max(last_user_scan)
where max(last_user_scan)is not null
union all
select lastaccess = max(last_user_lookup)
where max(last_user_lookup) is not null
union all
select lastaccess =max(last_user_update)
where max(last_user_update) is not null) temp)
FROM master.dbo.sysdatabases sysdb
left outer join sys.dm_db_index_usage_stats Idxus
on sysdb.dbid= Idxus.database_id
group by sysdb.name
Nice, useful for practical scenarios. Specially when platforms team is screaming for space on hosted environments 😊
Pingback: seo backlinking service
Pingback: Extra resources
Pingback: https://www.wasseem.org/
Pingback: คาสิโนออนไลน์
Pingback: didi referral code
Pingback: ไวอากร้า
Pingback: Creative Agency in Orlando
Pingback: ธนาธร จึงรุ่งเรืองกิจ
Pingback: 카지노사이트
Pingback: movies
Pingback: Car Crashes Compilation Russia/USA/Europe 2019 HD
Pingback: movies online
Pingback: karan johar
Pingback: Top Movies
Pingback: Movies1
Pingback: 11 10 2019
Pingback: smotretonline2015.ru
Pingback: Serial smotret
Pingback: kinokrad
Pingback: kinokrad 2020
Pingback: ñïèñîê íîâûõ ôèëüìîâ
Pingback: nha cai fun88
Pingback: Watch Tv Series Online
Pingback: casino
Pingback: Kinokrad 2019 Kinokrad Hd
Pingback: filmy-kinokrad
Pingback: kinokrad-2019
Pingback: filmy-2019-kinokrad
Pingback: serial
Pingback: cerialest.ru
Pingback: cornhole board dimensions
Pingback: dorama hdrezka
Pingback: HDrezka
Pingback: kinosmotretonline