开发者

Quick / Built-in method for detecting table change in SQL Server?

开发者 https://www.devze.com 2022-12-24 14:07 出处:网络
Is there a quick and easy way of telling if a table has changed in SQL Server? (I\'m using SQL Server 2005). Something like an incrementing ID somewhere that updates on 开发者_运维技巧each INSERT, DEL

Is there a quick and easy way of telling if a table has changed in SQL Server? (I'm using SQL Server 2005). Something like an incrementing ID somewhere that updates on 开发者_运维技巧each INSERT, DELETE or UPDATE that I can keep track of. I noticed there is a sys.objects.modify_date column for each table, but I don't think it's quite what I want because the docs say:

Date the object was last modified by using an ALTER statement. If the object is a table or a view, modify_date also changes when a clustered index on the table or view is created or altered.


Take a look at sys.dm_db_index_usage_stats from Pinal Dave. From the link:

SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'AdventureWorks')
AND OBJECT_ID=OBJECT_ID('test')
0

精彩评论

暂无评论...
验证码 换一张
取 消