For many reasons SQL Server DBAs need to find the last date and time of an update on a sql table. The SQL Server DMV sys.dm_db_index_usage_stats can supply enough information to allow the DBA to make a good estimate of the time. In this case I needed to create a list candidates for tables to be deleted. The data became bloated with a number of different temp tables . The one drawback of using the DMV is that data is refreshed after every SQL Server restart. This script lists all tables in the current database, with various columns assisting in deciding the last update. SELECT tbl.name ,ius.last_user_update ,ius.user_updates ,ius.last_user_seek ,ius.last_user_scan ,ius.last_user_lookup ,ius.user_seeks ,ius.user_scans ,ius.user_lookups FROM sys.dm_db_index_usage_stats ius INNER JOIN sys.tables tbl ON (tbl.OBJECT_ID = ius.OBJECT_ID) WHERE ius.database_id = DB_ID() last_user_update - Time of last user update. user_updates - Number of updates by user queries. last_user_seek - Time of last user seek . last_user_scan - Time of last user scan. last_user_lookup - Time of last user lookup. user_seeks - Number of seeks by user queries. user_scans - Number of scans by user queries. user_lookups - Number of bookmark lookups by user queries Related Posts SQL Server – Last DML operation SQL Server - Calculate table size with existing data How to request SQL Server troubleshooting
【版权声明】
本站部分内容来源于互联网,本站不拥有所有权,不承担相关法律责任。如果发现本站有侵权的内容,欢迎发送邮件至masing@13sy.com 举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
上一篇: 更快的distinct
下一篇: Sql Server2005性能诊断