Created
July 24, 2018 02:01
-
-
Save chrismckelt/9f1ed2ca338649a1efe4109d64083c07 to your computer and use it in GitHub Desktop.
sql last backups
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
;with backup_cte as | |
( | |
select | |
database_name, | |
backup_type = | |
case type | |
when 'D' then 'database' | |
when 'L' then 'log' | |
when 'I' then 'differential' | |
else 'other' | |
end, | |
backup_finish_date, | |
rownum = | |
row_number() over | |
( | |
partition by database_name, type | |
order by backup_finish_date desc | |
) | |
from msdb.dbo.backupset | |
) | |
select | |
database_name, | |
backup_type, | |
backup_finish_date | |
from backup_cte | |
where rownum = 1 | |
order by database_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment