November 15, 2025 at 7:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
November 16, 2025 at 11:57 pm
powershells remove-item
November 17, 2025 at 9:04 am
Switch your cleanup step to a SQL Agent PowerShell step using Remove-Item. More reliable and works fine in SQL 2022.
December 3, 2025 at 4:26 am
Hey,
Instead of using xp_delete_file you can use PowerShell script or a CMD script, and both work well for deleting old files.
December 3, 2025 at 9:41 pm
I think your only two options from t-sql are xp_cmdshell or xp_delete_file. I think the former gives you more options to execute something that manages files. I would separate out logic to a script of some sort (PoSh, Bash, CMd, Python, etc) on the file system and then let your xp_cmdshell call that. You could also output logs that way, or even have your module insert logs into a table.
This would also let you call that script/module with SQL Agent if you wanted. You could grant rights (or use a proxy) to call sp_start_job.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply