November 2, 2007 at 2:26 am
Hi all,
As you maybe know already, there is a bug SQL2005+SP2 with this issue, even if you mention in the maintenance plan step that you want the old files be deleted within the one subdirectory level, the files remains untouchable because of a bug, my question is if someone knows about an existing fix for that bug ?
Maybe another solution ?
Thanks,
Victor
DBA
November 2, 2007 at 9:28 am
The solution that is used sometimes is to create a job step of the type ActiveX Script and paste this with replacing FolderName variable value with your folder and subfolder path and you have to specify how many days - the current example is for 3 days and it deletes all files exactly 3 days old. You may want to replace it with "more then 3 days" or something. Also you may want to filter by extensions
Dim FSO 'As Scripting.FileSystemObject'
Dim Folder 'As Scripting.Folder'
Dim Files 'As Scripting.Files'
FolderName = "C:\MyFolder\MySubfolder"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(FolderName)
Set Files = Folder.Files
FOR EACH File In Files
IF DateDiff("d", Now,file.DateCreated) = -3 THEN
FSO.DeleteFile File,true
' This deletes all files , regardless of extension, and even if they are readonly files.'
END IF
NEXT
Set Files = Nothing
Set Folder = Nothing
Set FSO = Nothing
Regards,Yelena Varsha
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply