Alternate for xp_delete_file

  • alternate for xp_delete_file

    • This topic was modified 3 weeks, 1 days ago by PJ_SQL.
    • This topic was modified 3 weeks, 1 days ago by PJ_SQL.
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • powershells remove-item

  • Switch your cleanup step to a SQL Agent PowerShell step using Remove-Item. More reliable and works fine in SQL 2022.

  • Hey,

    Instead of using  xp_delete_file you can use PowerShell script or a CMD script, and both work well for deleting old files.

  • 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