SSIS / SQLCMD: Delete old TXT files

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:
sp_DeleteOldTXTFiles

Advertisements

One thought on “SSIS / SQLCMD: Delete old TXT files

  1. Pingback: SSIS: Delete old files with PowerShell (via a ‘Execute Process Task’) #FileRetentionPeriod | Clint Huijbers' Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s