Hm. I could be wrong on this, but I believe xp_delete_file will only work on SQL Server backup and report files; that is, files ending in .trn, .bak, and .rpt. It looks like you're trying to delete .txt files with it, which shouldn't work. You may have to resort to using a PowerShell script to do this instead.
I would like to thank each one of you for your replies and suggestions.
No, this is not a test question. We have jobs that are supposed to delete files older than a certain number of days. For some reasons, the job is not working on our text files.
Like hisakimatama said in the second post on this thread (quoted above, as well), xp_delete_file won't delete .txt files. It works only for backup and report files and they have to have the correct embedded header, to boot.
As a bit of a sidebar, this demonstrates that great care and very careful research/testing should be done before using any undocumented stored procedure.
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair
How to post code problemsHow to post performance problemsForum FAQs