欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

获取数据表最后最后访问,修改,更新,扫描时间

程序员文章站 2022-09-04 13:13:50
数据分析,需要获取数据每一张表的最后访问,修改,更新,扫描时间等: SELECT [Table Name] = [name],[Create Date] = create_date,[Modify Date] = modify_date,[Last User Update] = last_user_ ......

数据分析,需要获取数据每一张表的最后访问,修改,更新,扫描时间等:

 

 

select [table name] = [name],[create date] = create_date,[modify date] = modify_date,[last user update] = last_user_update,[last user scan] = last_user_scan

from sys.tables as t
inner join (select [tablename] = object_name(object_id),last_user_update, last_user_scan
from sys.dm_db_index_usage_stats
where database_id = db_id('test')) as sd
on (t.[name] = sd.[tablename])
go