Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2008-07-28 : 11:19:47
|
| Hi, I have successfully deployed my reports and also have been doing great on scheduling the report and saving it to a file in my D drive on the server. The schedules runs everyday no matter what. I will have about 10 files saved for each day. However, I just want to keep files that are just as fresh as 2 days old, I don't need those files that were saved before that. Can I make this happen and make sure that it is an automated task? Is there any way? |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-07-28 : 12:53:02
|
| You can limit number of copies of history. |
 |
|
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2008-07-28 : 13:03:15
|
| How can I achieve this ? and what tool would I be using to do this |
 |
|
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2008-07-28 : 13:49:49
|
| This is what I came across while searching the net .http://www.mssqltips.com/tip.asp?tip=1324I have tested the script and it does what I need to do.Since there is no SQL Server on the server where the reports are located,how can I automate a scheduler everyday to delete the files.I have created .bat file based on the url above.Any ideas & suggestions? |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-07-28 : 22:57:32
|
| You can run the batch file with windows task scheduler in control panel -> scheduled task. |
 |
|
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2008-07-29 : 09:02:04
|
| Hi rmiao, Thanks for your suggestion.Ive come across another problem now.The script that I have only works for 1 level of subfolder.My current dir structure look like the below.C:\Client\ServerName\Report1 [ Here is where the reports are held]Guys,I need to be able to clean up all reports that are older than 2 days in the Report1 folder.Any help?Here is the current code for 1 level of subfolder:-iDaysOld = 2strPath = "C:\Client\ServerName\Report1\" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) Set colSubfolders = objFolder.Subfolders Set colFiles = objFolder.Files For Each objFile in colFiles If objFile.DateCreated < (Date() - iDaysOld) Then 'MsgBox "Dir: " & objFolder.Name & vbCrLf & "File: " & objFile.Name objFile.Delete End If Next For Each objSubfolder in colSubfolders Set colFiles = objSubfolder.Files For Each objFile in colFiles If objFile.DateCreated < (Date() - iDaysOld) Then 'MsgBox "Dir: " & objSubfolder.Name & vbCrLf & "File: " & objFile.Name objFile.Delete End If Next Next |
 |
|
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2008-07-30 : 13:30:21
|
| I have solved this problem myself. I just added the path to the specific folder and it does what I want. Thanks everyone for participating. |
 |
|
|
|
|
|