Basically it's a DBA’s responsibility to maintain the database server cleanup. Most probably a developer or some application owner will ask to restore the UAT database on the production server for some reason, forgotting to drop the same. When the audit starts our auditor asks why the unwanted database or objects are present on production server. In that case it is very difficult to determine which database is used or not from potentially hundreds of databases.
To resolve such type of issue I have implemented following stored procedure which, provides the object wise last used date of all databases which are available in single instance.
How to Use:
-
Create a “Database_Object_Last_used_details” store procedure on your master database
-
And execute the same whenever you want to fetch details
I would like to request, If you have any more idea to improve the above alert notification script please suggest them in the comments.
Thank & Regards,
Abhijit Y Shedulkar
(MSSQL Team Lead -CIPL)