Friday, 27 July 2012

SQL Server - Find time of last database backup

Find the last time your Database was backed up

Quick one - wanting to find out the last time your DB was backed up?

This SQL Statement will show all database backup times on a server.

SELECT sdb.Name AS DatabaseName, 
       MAX(bus.backup_finish_date) AS LastBackUpTime
FROM sys.sysdatabases sdb
LEFT JOIN msdb.dbo.backupset bus 
    ON   bus.database_name = sdb.name
GROUP BY sdb.Name

Also in SQL 2008 there are a load of good built in reports which you can access by

  • Selecting the database
  • Select Reports 
  • Select Standard Reports 
  • Select the report you want such as "Disk Usage" 
This shows you the disk usage and log file usage for your database in a nice pie chart as well as numerical terms.

If you didn't know about it, its a good little feature.

No comments: