SQL Server database last updated date time
Asked Answered
T

3

26

Is there any sql script to find out when the database in SQL server is last updated?

I want to know the last updated date time for the changes done on meta data of the database rather than actual data inside the table. Particularly when:

  • Any new table is created/dropped from Database.
  • Any new column is added/removed from table in the Database.
  • Any new views/Stored Procedures/Functions are added/altered inside the Database.
Trimer answered 9/4, 2015 at 9:45 Comment(0)
U
49

Look in sys.objects should be enough, try this query

 select * from sys.objects
order by modify_date desc
Unreality answered 9/4, 2015 at 10:10 Comment(0)
M
7

This will return last modified date time + name of updated item + description what was updated (table, stored procedure, etc)

SELECT TOP 1 name, modify_date, type_desc
FROM  sys.objects
ORDER BY modify_date DESC
Menorah answered 9/4, 2015 at 10:15 Comment(0)
D
0
SELECT 
   [rs].[destination_database_name], 
   [rs].[restore_date], 
   [bs].[backup_start_date], 
   [bs].[backup_finish_date], 
   [bs].[database_name] as [source_database_name], 
   [bmf].[physical_device_name] as [backup_file_used_for_restore]
FROM msdb..restorehistory rs
INNER JOIN msdb..backupset bs ON [rs].[backup_set_id] = [bs].[backup_set_id]
INNER JOIN msdb..backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] 
Dowden answered 15/1, 2020 at 16:47 Comment(1)
Check this, this code gives you all information about backup and restore date.Dowden

© 2022 - 2025 — McMap. All rights reserved.