Skip to content

Get LastUpdatedTablesForDatabase

MikeyMing edited this page Dec 10, 2019 · 5 revisions

Introduction

This is useful for determining what parts (if any) of a database are being written to. It works by examining the sys.dm_db_index_usage_stats DMV which stores usage stats since the last server restart.

Usage

Get-LastUpdatedTablesForDatabase -instance . -Database DBA | ft

This will look at the DBA database on the local instance and uses the PowerShell Format-Table cmdlet to format the output for us.

Example output follows:

Here we can see that the CaptureLogins and Log table are being written to, at least since the server was last restarted as these all have non-zero values in the user_updates and LastUpdate columns. Equally, the longer the instance has been up, the more reliable the data.

We need to be careful about drawing any conclusions from the Seeks and Updates columns, as these may be coming from housekeeping jobs, although a very high number is usually indicative of user access.

Clone this wiki locally