DECLARE @BackupFile varchar(255), @DB varchar(30),
@Description varchar(255), @IsSunday bit,
@Name varchar(30), @MediaName varchar(30)
SELECT @DB = DB_NAME() ,
@IsSunday = CASE Datepart(dw , CURRENT_TIMESTAMP) WHEN 1 THEN 1 ELSE 0 END,
@Name = @DB + '( Daily Backup )',
@MediaName = @DB + '_Dump' + CONVERT(varchar, CURRENT_TIMESTAMP , 112),
@BackupFile = '\\somesrvr\backup\' + @DB + '_' +
CASE @IsSunday WHEN 1 THEN 'Full' ELSE 'Diff' END + '_' +
CONVERT(varchar, CURRENT_TIMESTAMP , 112) +
REPLACE(LEFT(CONVERT(varchar, CURRENT_TIMESTAMP, 108), 5), ':', '') +
'.BAK',
@Description = CASE @IsSunday WHEN 1 THEN 'Normal' ELSE 'Differential' END +
' Backup at ' + CONVERT(varchar, CURRENT_TIMESTAMP) + '.'
IF @IsSunday = 1
BACKUP DATABASE OSITraffic TO DISK = @BackupFile
WITH NAME = @Name, DESCRIPTION = @Description ,
MEDIANAME = @MediaName, MEDIADESCRIPTION = @Description ,
STATS = 10
ELSE
BACKUP DATABASE OSITraffic TO DISK = @BackupFile
WITH DIFFERENTIAL, NAME = @Name, DESCRIPTION = @Description ,
MEDIANAME = @MediaName, MEDIADESCRIPTION = @Description ,
STATS = 10
This page was last updated on May 01, 2006 04:28 PM.