0
votes

I have a temp directory on my website where users export data in .csv files.

The newer intranet apps delete the file after it's sent to the client but the legacy apps just leave the files in this directory.

I'd like to create a task to clean this directory nightly. There can be .csv files and directories with files in them.

Basically I want to run:

del *.* /s
rd /s

...every night at midnight.

Would love to do it with a SQL maintenance task but that only runs on the actual SQL server and doesn't work with mapped drives (unless I'm missing something).

How does one go about performing this task?

Can it be done through SQL server somehow?

2
Why bother? Just make a script and run it as a scheduled task in Windows. - lc.
How do I do that? Using the task scheduler? - Tom
Yeah, just save what you have as a .bat file, and use the task scheduler. - lc.

2 Answers

1
votes

You have the option of creating "Jobs" that run stored procedures or bits of code. These jobs can be scheduled to run daily, weekly, etc. Check out this thread: How can i create SQL Agent job in SQL Server 2008 standard?

0
votes

Sounds like you may be using SQL Server Express Edition for which Microsoft removed the SQL Agent on 2008 and above. In cases like this you're best choice is using the Windows Scheduler to run your commands via a batch file.