An easy way to delete old TXT files on your server is to use a SQL Agent Job and can be used with my previous GenerateScripts SP’s.
For this, I wrote a SP that uses the SQLCMD utility of SQL Server instead of SSIS because it’s lean and easy to implement.
A simple folder lookup by using SQLCMD:
I wrote to different Stored Procedures:
– Delete TXT files based on the file’s filename (for example:’_yyyymmdd‘)
– Delete TXT files based on the file’s creation/modification date
Download both SP’s here: