I need to run a job through SQL Server Agent. A job that deletes obsolete files from the application server based on retention days (obsolete physical files, files which are not stored in MS SQL). Where should I begin with? Does the job have to be a stored procedure?
To comply with the coding standards and our backend jobs are consolidated in sql server agent and will be scheduled to run on a certain time of day. Is it possible to create a batch file and run it through ms sql server agent? Thanks
Thanks for your reply. Btw, i will not be dealing with .bak files. I have to housekeep a certain folder's content based on retention days. My files have timestamps.
Thanks for the info.
Forfiles /P C:\PATHTOFILES /D -5 /C "cmd /c DEL /q @path"
-will this be the only line of code that I need? and then I can integrate it to MS SQL?
do you have any idea where I can test this code?
Forfiles /P C:\PATHTOFILES /D -5 /C "cmd /c DEL /q @path"
Apologies for too much questions, im very new with ms sql and batch files.
Thanks, it worked on my local PC when i ran it in cmd. The housekeeping job will be deployed and scheduled in SQL Server Agent(ServerA) and I need to housekeep folders on the Application Server (ServerB). I tried to test the code and used this code:
Forfiles /P \ServerB\PATHOFFILES /D -5 /C "cmd /c DEL /q @path" but it doesnt work, its says "ERROR: UNC paths (\machine\share are not supported)" any idea?
they say pushd will work, but i cant seem to make this work:
pushd \ServerB\D:\Folder Forfiles /P "\ServerB\D:\Folder " /D -5 /C "cmd /c DEL /q @path" popd