How to Check when a Table was Last Updated

Paopatsin/ August 22, 2020/ Database, MS SQL, Technology

Please read our Disclaimer

Works With
-Microsoft SQL Server 2016 (RTM) – 13.0.1601.5 (X64)
-Microsoft SQL Server 2008 (RTM) – 10.0.1600.22 (X64)

Command:

SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update, * FROM sys.dm_db_index_usage_stats WHERE database_id = DB_ID(‘[replace with your database name]’) AND OBJECT_ID = OBJECT_ID(‘[replace with your table name]’)

Steps and Sample Usage:

  1. Open and log into your SQL Management Studio
  2. Open a New Query Windows or (CTRL+N)
  3. Copy and Paste the code block above to your Query Window
  4. Replace the DB_ID with the name of your Database and replace the OBJECT_ID with the name of your Table
  5. Execute the query by pressing F5.

Sample Data:
-AdventureWorks2016 Database

Share this Post