dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Get-DbaDatabaseLastUsed

Open SirCaptainMitch opened this issue 9 years ago • 4 comments

Is this a feature OR bug: Enhancement

https://trello.com/c/s2fnvD0C

Last_Access.zip

Additional comments @Jagoop "Use data from sys.dm_db_index_usage_stats to determine when the database was last used by users. Max of last_user_seek, last_user_scan, last_user_lookup = last time a user read. last_user_update = last time a user wrote/updated.

The method isn't foolproof, but combined with the database created timestamp and the instance restert (from tempdb creation date), it can assist in discovering databases that are unused."

@wsmelton "Reading "Watch-SqlDbLogin" it would seem this may be close or just another option to doing the same thing for databases. Watch command is named for logins but it can be the same premise around databases as well.

But this command could still prove useful. Could also add in something fancy like just doing a "Watch-DbaDatabase" instead and periodically poll the index usage stats....or create an Trace/XEvent to watch for login activity, then load that into table or display output."

SirCaptainMitch avatar Jan 18 '17 23:01 SirCaptainMitch

@SQLDBAWithABeard - would you be able to add this property to Get-DbaDatabase? Ensuring that it's only added for servers that support it, otherwise, $null. If not, let me know. i recall you loving that in dbareports.

potatoqualitee avatar Jul 23 '17 16:07 potatoqualitee

Absolutely

SQLDBAWithABeard avatar Jul 23 '17 16:07 SQLDBAWithABeard

yessssss!

potatoqualitee avatar Jul 23 '17 16:07 potatoqualitee

this got merged a while ago. Closing.

niphlod avatar Nov 30 '17 21:11 niphlod