How do I delete a .txt file with TSQL, without using xp_cmdshell

自古美人都是妖i 提交于 2019-12-11 02:14:06

问题


I am trying to use TSQL to delete a .txt file at the end of a process. My restriction is that I cannot use xp_cmdshell. I had tried using the undocumented xp_delete_file but from what I can find it will only delete SQLServer native .ldf or .bak files. Is there another approach that can be used? I am running in SQL server 2008 R2.


回答1:


Use SQL Server Agent CmdExec job step? This can run "del"...

http://msdn.microsoft.com/en-us/library/ms190264.aspx

In step 8 you'd have del c:\importpath\toasted.txt

Your comment to your question states you are running a "SQL job", so no need to overkill with CLR or sp_OA% solutions :-)



来源:https://stackoverflow.com/questions/4830464/how-do-i-delete-a-txt-file-with-tsql-without-using-xp-cmdshell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!