I have a text file in the name of BankDetails_09302014_153054.txt in one folder. I need to create a SQL job which will delete old files except current datetime file. (ie BankDetails_10012014_103104.txt). This sql job need to be execute on daily basis. Kindly give me some suggestions to achieve my requirement
Asked
Active
Viewed 719 times
1 Answers
0
A similar question was answered here on how to get your Creation and modifieddate of a file
Once you get your respective date you can compare and delete. Hope this helps

Nuru Salihu
- 4,756
- 17
- 65
- 116
-
I am expecting something related to xp_cmdshell. Using this one we can delete the required files. But I am stuck with the place to delete the file based on filename date. – pyborg Oct 01 '14 at 05:27
-
Oic. Have not perform the operation before. But it seems to me if i can return the dates then we can compare and delete. I found an interesting article Here = > http://www.kodyaz.com/articles/delete-file-from-sql-server-xp-cmdshell-ole-automation-procedures.aspx on how to delete the files with xp_cmdshell . Perhaps may b will try in my free time. Thought it might helps. – Nuru Salihu Oct 01 '14 at 07:27