backup
백업기록 조회
MSSQL 2005 이상부터 사용이 가능합니다. IF OBJECT_ID('TEMPDB..#TMP_BACKUPHISTORY') IS NOT NULL DROP TABLE #TMP_BACKUPHISTORY SELECT * INTO #TMP_BACKUPHISTORY FROM (select s.server_name, s.database_name, workname = s.name, s.backup_set_id, s.backup_finish_date,mdf_file=f.physical_name , backup_file = m.physical_device_name ,f.file_sizefrom msdb..backupset s, msdb..backupmediafamily m , msdb..backupfile fwhere..
2년전 백업 정보 삭제 쿼리(mssql 2000)
DECLARE @backupID intDECLARE @mediaID intDECLARE @restoreID int DECLARE @year char(4)DECLARE @month char(2)DECLARE @day char(2)DECLARE @deleteday char(10) SET @year = year(getdate())-2 -- 2년전SET @month = month(getdate())SET @day = day(getdate())IF len(@month) = 1 SET @month = '0'+ @monthIF len(@day) = 1 SET @day = '0'+ @daySET @deleteday = @year +'-'+ @month +'-'+ @day SELECT TOP 1 @backupID = b..