Last active
April 12, 2018 10:00
-
-
Save juanonsoftware/de04743be3e008d82dd61710d026af0d to your computer and use it in GitHub Desktop.
Script to get all backup of a SQL Server database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @dbName varchar(255); | |
set @dbName = 'TestDB'; | |
SELECT m.physical_device_name, | |
b.backup_start_date, | |
b.backup_finish_date, | |
b.type, | |
b.backup_size/1024/1024 AS BackupSizeMB, | |
b.compressed_backup_size/1024/1024 as CompressedBackupSizeMB | |
FROM msdb.dbo.backupset b | |
JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id | |
WHERE b.database_name = @dbName | |
ORDER BY backup_finish_date DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To check if a file is existing by sql:
DECLARE @Result INT
EXEC master.dbo.xp_fileexist 'D:\Wip\Practices\OpenSource\FolderListioning\FolderToWatch\Config.txt', @Result OUTPUT
print @Result