LiCongMingDeShujuku / Get-How-Old-SQL-Database-Backups-Are

获取SQL数据库备份的历史

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLEVER DATA GIT REPO

获取SQL数据库备份的历史

Get How Old SQL Database Backups Are

发布-日期: 2015年09月01日 (评论)

#

Contents

中文

这里有一些可以显示备份的时间的快速的SQL逻辑。

English

Here’s some quick SQL Logic that will show you the age of your backups.


Logic

use master;
set nocount on
 
select
'database' = upper(bs.database_name)
,   'backup date' = datename(dw, bs.backup_finish_date) + ' ' + convert(char, bs.backup_finish_date, 9) ,   'type' =
case bs.type
when 'L' then 'TLOG'
when 'D' then 'FULL'
end
,   'num days old' = left((datediff(s, bs.backup_finish_date, getdate())/86400.0),6) ,  'location' = bmf.physical_device_name
from
msdb..backupset bs join msdb..backupmediafamily bmf on bs.media_set_id = bmf.media_set_id
--where
--  bs.database_name = 'mydatabase'
--  and bs.type = 'D'
order by
bs.backup_finish_date desc

WorksEveryTime

Build-Info

Build Quality Build History
Build-Status
Coverage
Nuget
Build history

Author

  • 李聪明的数据库 Lee's Clever Data
  • Mike的数据库宝典 Mikes Database Collection
  • 李聪明的数据库 "Lee Songming"

Gist Twitter Wordpress


License

LicenseCCSA

Lee Songming

About

获取SQL数据库备份的历史