HOW TO DELETE BACKUP FILES OLDER THAN 2 DAYS USING A SCRIPT | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

HOW TO DELETE BACKUP FILES OLDER THAN 2 DAYS USING A SCRIPT

HiAnyone who knows how i can delete my backup files xxxxxx.bk using a script so that i can run it as a job? pls help.
What about using backup wizard to generate a job doing what you want?

I use the forfiles.exe program to help with this on some systems where I can’t use the automated job.
D:utiitylforfiles.exe -pD:MSSQLBackups -m*.bak -d-2 -s -c"CMD /C DEL @FILE"
It’s just a single step in a SQL Agent job.
It was originally part of the Windows 2000 Resource Kit.

That may be issue with FORFILES applicaton, you could try http://www.sqlservercentral.com/scripts/Administration/62729/ for script based.

I got to throw in this to an old thread!
It works and is all T-SQL. very nice. Just ensure you change the code IF @OSVersion = ‘5.2’ to IF @OSVersion >= ‘5.2’
and all is well! http://www.sqlservercentral.com/scripts/Administration/62729/ Just had to share:)
]]>

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |