Delete files older than 7 days with SQL Script

  • Hi All, I have seen some posts on this, but could not find the exact script I needed:

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

    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.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply