Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Delete files older than 7 days with SQL Script Expand / Collapse
Author
Message
Posted Friday, July 27, 2012 5:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 9, 2013 7:01 AM
Points: 1, Visits: 11
Hi All, I have seen some posts on this, but could not find the exact script I needed:

EXECUTE master.dbo.xp_cmdshell 'forfiles /p "D:\Path" /s /m *.* /c "cmd /c Del @path" /d -7'

This works very well, but you need an MS operating system: Windows Server 2003 or Vista or newer version.

Hope this helps with deleting multiple files.
Post #1336404
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse