Find the last time table was updated

后端 未结 6 943
渐次进展
渐次进展 2020-12-23 12:10

I want to retrieve the last time table was updated(insert,delete,update).

I tried this query.

SELECT last_user_update
FROM sys.dm_db_index_usage_stat         


        
6条回答
  •  渐次进展
    2020-12-23 12:39

    If you're talking about last time the table was updated in terms of its structured has changed (new column added, column changed etc.) - use this query:

    SELECT name, [modify_date] FROM sys.tables
    

    If you're talking about DML operations (insert, update, delete), then you either need to persist what that DMV gives you on a regular basis, or you need to create triggers on all tables to record that "last modified" date - or check out features like Change Data Capture in SQL Server 2008 and newer.

提交回复
热议问题