Last “Touch” on each Database per Instance

Enhanced the T-SQL Script by adding last_user_scan, last_user_seek and last_user_lookup and compared the values against each other to get the most recent access to the very table.


Today i was asked if some of the databases on a specific instance were in use or not.
As this is an interesting question that could be easily answered by the SQL Server DMVs i wrote a little script to answer this question.

It creates a temporary table with five colummns named DatabaseName, TableName, IndexType, LastTouch and ActualDate (this is just for comparison).
It then executes sp_MSforeachdb and inserts a record for each database within the instance except for the system databases.
It then tells us which table was recently used and when.

View original post

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s