Home > Uncategorized > Delete old backup files SQL script

Delete old backup files SQL script

April 27, 2011

The following script deletes .bak files older than 7 days from F:SharesBackup2Disk

DECLARE @DeleteDate datetime
SET @DeleteDate = DateAdd(day, -7, GetDate())
EXECUTE master.sys.xp_delete_file 0,N’F:SharesBackup2Disk’,N’bak’,@DeleteDate,1

%d bloggers like this: