Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple Integration Service package which has one SQL Task as shown below;

  • WLSTAGE Bakup using Red Gate: Calls master..sqlbackup to backup database

Here is the SQL to run the actual backup

exec master..sqlbackup '-E -SQL "BACKUP DATABASE [WLSTAGE] TO DISK = ''\\Backups\<AUTO>'' WITH COMPRESSION = 1, INIT, MAILTO = ''<left blank intentionally>'', VERIFY"'

Since I have specified the backup file name as <AUTO>, I am wondering if there is a simple way to remove backups older than 2 days (if possible, without having to write any plumbing code to parse the file name).

alt text

share|improve this question
up vote 1 down vote accepted

I'm not sure what the AUTO statement does, but you are probably aware of the Maintenance Cleanup task. Does it not do what you need?

I like powershell for things like this as well.

(get-item -path "d:\perflogs\*" | where {$_.creationTime -lt ((get-date) - (new-timespan -days 30))} | where {$_.extension -eq ".blg"}) | remove-item
share|improve this answer
@Sam: Specifying <AUTO> creates a file name dynamically using parent's directory name and current date stamp - Back to the main point, is it possible to call powershell scripts within SSIS package as you have suggested? – Sung Jan 20 '10 at 18:07
I suppose it would be a command line call you could put in a job step. Did you try the Maintenance Cleanup task? – Sam Jan 22 '10 at 0:23
Thanks Sam, I have decided to use PowerShell in Execute Process Task mentioned in this StackOverflow answer -… – Sung Jan 29 '10 at 14:19
Glad you got it sorted out. I might consider a .net script task solution as well, to keep all the code in one place. I think you can run powershell from inside .net as well, so the .net would just be a bit of a wrapper. – Sam Feb 1 '10 at 17:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.