Situatie
Mai jos este o procedura sql care afiseaza numarul de zile de la ultimul backup al fiecarei baze de pe un server Microsoft SQL Server.
Solutie
create procedure NumeberOfDaysSinceLastDatabaseBackup_prc
as
SELECT
DATABASE_NAME,
CONVERT( VARCHAR(20) ,
MAX(BACKUP_FINISH_DATE)) AS LAST_BACKUP,
DATEDIFF(D, MAX(BACKUP_FINISH_DATE), GETDATE()) AS DAYS_SINCE_LAST_BACKUP
FROM MSDB.DBO.BACKUPSET
WHERE TYPE = ‘D’
GROUP BY DATABASE_NAME
ORDER BY DAYS_SINCE_LAST_BACKUP DESC
Leave A Comment?