Question: When was Database Last Backed Up in SQL Server?
Answer: I had received this question doing my recent training on SQL Server Performance Tuning. Though this training is about performance tuning, I do enjoy answering pretty much all the questions for SQL Server.
Here is the script which will list all the different types of backup for your server.
-- Get Backup History for required database SELECT TOP 100 s.database_name, CASE s.[type] WHEN 'D' THEN 'Full' WHEN 'I' THEN 'Differential' WHEN 'L' THEN 'Transaction Log' END AS BackupType, m.physical_device_name, CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSize, CAST(DATEDIFF(second, s.backup_start_date, s.backup_finish_date) AS VARCHAR(4)) + ' ' + 'Seconds' TimeTaken, s.backup_start_date, s.server_name, s.recovery_model FROM msdb.dbo.backupset s INNER JOIN msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id ORDER BY backup_start_date DESC, backup_finish_date GO
When you run above query, it will display following resultset:
You can clearly see above query will display the backup name and type of the backup. One of the my favorite columns is time taken column to complete the backup as that also tells us lots about the entire backup process is set up.
Earlier I have written a blog post about backup timeline and it is one of the most popular blog posts so far. I encourage everyone to read this blog post.
A Must Read: SQL SERVER – Backup Timeline and Understanding of Database Restore Process in Full Recovery Model
Reference: Pinal Dave (https://blog.sqlauthority.com)