SQL Server‎ > ‎

Delete SQL Backups Older Than A Certain Date


Access to the xp_cmdshell has to be turned on.   


EXEC xp_cmdshell 'FORFILES /p E:\SQLBACKUPs\CPMAIN /s /m *.bak /d -15 /c "CMD /C del /Q /F @FILE"'
EXEC xp_cmdshell 'FORFILES /p E:\SQLBACKUPs\BOSS3 /s /m *.bak /d -15 /c "CMD /C del /Q /F @FILE"'
EXEC xp_cmdshell 'FORFILES /p E:\SQLBACKUPs\msdb /s /m *.bak /d -15 /c "CMD /C del /Q /F @FILE"'
Comments