Geeks With Blogs
DevJef's Mumbo-Jumbo «There's a bit of SQL in all of us»

How many times do you wonder about when an object was last updated? You can find out by using the default sysobjects in SQL Server:


USE Adventureworks

DECLARE @DBID INT = DB_ID('Adventureworks')

SELECT AS TableName,
FROM sys.dm_db_index_usage_stats ddius
JOIN sys.objects o
	ON o.object_id = ddius.object_id
WHERE database_id = @DBID
ORDER BY ddius.last_user_update DESC


This will give you the last_user_update, which is based on indexes. The Insert, Delete or Update are stored in the sys properties of the database. So this only works if there is an index of some sort is used on the object!

Posted on Wednesday, September 21, 2011 8:56 PM SQL Scripts | Back to top

Comments on this post: Last update on object?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DevJef | Powered by: