SQL DBA Tutorial

How to Find All Database Backup Time History

How to Find All Database Backup Time History

In this Article,I am sharing T-SQL Script to find the all Database backup related history information of SQL Server.

DECLARE @dbname sysname
SET @dbname = NULL
SELECT qt.user_name AS [User],
qt.database_name AS [Database],
qt.server_name AS [Server],
qt.backup_start_date AS [Backup Started],
qt.backup_finish_date AS [Backup Finished]
,CAST((CAST(DATEDIFF(s, qt.backup_start_date, qt.backup_finish_date) AS int))/3600 AS varchar) + ‘ hours, ‘
+ CAST((CAST(DATEDIFF(s, qt.backup_start_date, qt.backup_finish_date) AS int))/60 AS varchar)+ ‘ minutes, ‘
+ CAST((CAST(DATEDIFF(s, qt.backup_start_date, qt.backup_finish_date) AS int))%60 AS varchar)+ ‘ seconds’
AS [Total Time]
FROM msdb.dbo.backupset qt
WHERE qt.database_name IN (SELECT name FROM master.dbo.sysdatabases)
ORDER BY qt.database_name

After you run the script, you will get the Below result.

How to Find Long Running Queries in SQL Server

Backup and Restore Interview Question and Answers

Get SQL Dba Tutorial Updates!

Signup now and receive an email once I publish new content.

Thank you for subscribing.
Something went wrong.
I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Exit mobile version