|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, March 07, 2013 5:45 PM
Points: 184,
Visits: 1,029
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 6:37 AM
Points: 7,
Visits: 168
|
|
The 'Forfiles' command can do this in one line of code. I don't know why we have to re-invent the wheel here.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, March 07, 2013 5:45 PM
Points: 184,
Visits: 1,029
|
|
Forfiles is not included in every os by default. I needed to make sure that the code was supportable with no additional external software requirements (resource kit executables and such).
The Forfiles command would make life quite a bit simpler and it could be easily added to it and the FOR command removed...
Your friendly High-Tech Janitor... :)
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, August 27, 2012 2:50 AM
Points: 4,
Visits: 124
|
|
Thanks for the script. Months ago I was looking for a scritp like this one with an additional feature: recursively delete old files in the selected folder an sub-folders. I suppose it is difficault to deal with sub-folders at any level using T-SQL and finally I use an external exe program written in C# (deleteold.exe from codeproject). Anyway, I would prefere this functionality in T-SQL  Regards
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 7:29 AM
Points: 100,
Visits: 49
|
|
| Just curiuos if anyone is using this? I'm planning to implement this at a disaster recovery site. On our live SQL Server we back up the db and ftp it to another location. I figure that I can run this as a job at the DR site to delete the old backups.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, March 07, 2013 5:45 PM
Points: 184,
Visits: 1,029
|
|
The code presented is actually about six months older than the date on it - I've been using this method on around 150 servers since it's inception with no issues.
Edit:
FWIW, you can add a PRINT @DynDelete and if you schedule the code through SQLAgent you'll have the delete command output so you can record what is being deleted by having the job step append its output to a file. [My production version of this logs the deletes to a table]
Your friendly High-Tech Janitor... :)
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 7:29 AM
Points: 100,
Visits: 49
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:35 AM
Points: 139,
Visits: 4,605
|
|
If you want to use SQL instead of other applications and you're using SQL Server 2005, why you don't use the extended procedure xp_delete_file?
Personally I feel it quite restricted and I still use a delete command line that I create for myself when I was using SQL Server 2000.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 9:01 AM
Points: 30,
Visits: 237
|
|
| I'm trying it and getting all kinds of incorrect syntax error when parsing it.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, March 07, 2013 5:45 PM
Points: 184,
Visits: 1,029
|
|
It might be the extra characters that are 'added' to the script when posted.
Your friendly High-Tech Janitor... :)
|
|
|
|