In SQL Server 2005, can you easily determine the last time someone queried a database.
SQL Server can log event information for logon attempts and you can view it by reviewing the errorlog. By turning on the auditing level of SQL Server.
Another way to see if your database is in use is to look and see if the indexes are being used. Information on index usage is held in the sys. dm_db_index_usage_stats table since the last server reboot, and can be queried using this statement which can be tailored to select the data you need.
If a user wants to find out when was the last table updated he can query dynamic management view (DMV) – sys. dm_db_index_usage_stats and easily figure out when was the table updated last.
SELECT last_user_seek = MAX(last_user_seek), last_user_scan = MAX(last_user_scan), last_user_lookup = MAX(last_user_lookup), last_user_update = MAX(last_user_update) FROM sys.dm_db_index_usage_stats WHERE [database_id] = DB_ID()
One caveat with this method is that the information in the DMV will be cleared and nulled whenever you restart SQL Server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With