See below a simple script to find latest backup date time and physical location for all the Databases in a given SQL Server instance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
WITH Databse_Backup AS ( SELECT @@Servername AS [Server Name] , d.Name AS [Databse Name] , b.Backup_finish_date AS [Backup date], bf.Physical_Device_name AS [Physical Device name], RANK() OVER(PARTITION BY d.Name ORDER by Backup_finish_date desc) as latest FROM sys.databases d INNER JOIN msdb..backupset b ON b.database_name = d.name AND b.[type] = 'D' INNER JOIN msdb.dbo.backupmediafamily bf ON b.media_set_id = bf.media_set_id ) SELECT [Server Name],[Databse Name] ,[Backup date],[Physical Device name] FROM Databse_Backup WHERE latest=1 |
Leave a Comment