1

我想查找从未备份的数据库列表,我有代码列出所有数据库的上次备份时间:

SELECT  
      sdb.Name AS DatabaseName
    , COALESCE(CONVERT(VARCHAR(12), MAX(bus.backup_finish_date), 101), '-') AS LastBackUpTime
FROM sys.sysdatabases sdb
LEFT OUTER JOIN msdb.dbo.backupset bus ON bus.database_name = sdb.Name
GROUP BY sdb.Name
4

1 回答 1

0

试试这个——

IF OBJECT_ID('dbo.DbNeverBackUp') IS NOT NULL
   DROP TABLE dbo.DbNeverBackUp

SELECT [db_name] = sdb.name 
INTO dbo.DbNeverBackUp
FROM sys.sysdatabases sdb
LEFT JOIN msdb.dbo.backupset bus ON bus.database_name = sdb.name
WHERE bus.backup_finish_date IS NULL

SELECT * 
FROM dbo.DbNeverBackUp
于 2013-09-06T06:16:17.483 回答