码迷,mamicode.com
首页 > 数据库 > 详细

检查超过7天未备份的db

时间:2016-07-23 15:09:42      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

SELECT
dbs.[name] AS DatabaseName
FROM    master.sys.databases dbs
where dbs.database_id <> 2
AND dbs.[name] NOT IN
	(	SELECT
		bus.database_name as ‘name‘
		FROM msdb.dbo.backupset bus
		INNER JOIN msdb.dbo.backupmediafamily bume ON bus.media_set_id = bume.media_set_id
		WHERE
		dbs.database_id <> 2
		AND dbs.is_in_standby = 0
		AND dbs.source_database_id IS NULL
		AND dbs.[state] <> 1
		AND bus.backup_finish_date >= DATEADD(d, -7, GETDATE())

	)

检查超过7天未备份的db

标签:

原文地址:http://www.cnblogs.com/heqianjin/p/5698537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!