如何在不使用xp_cmdshell的情况下使用TSQL删除.txt文件 [英] How do I delete a .txt file with TSQL, without using xp_cmdshell

查看:108
本文介绍了如何在不使用xp_cmdshell的情况下使用TSQL删除.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用TSQL在过程结束时删除.txt文件。我的限制是我不能使用xp_cmdshell。我曾尝试使用未记录的xp_delete_file,但从我发现的内容来看,它只会删除SQLServer本机.ldf或.bak文件。
是否可以使用另一种方法?我正在SQL Server 2008 R2中运行。

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.

推荐答案

使用SQL Server Agent CmdExec作业步骤?这可以运行 del ...

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

http://msdn.microsoft.com/zh-cn/library/ms190264.aspx

在步骤8中,您将拥有 del c:\importpath\toasted.txt

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

您对问题的评论指出您正在运行 SQL工作,因此无需使用CLR或sp_OA%解决方案就可以解决问题:-)

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

这篇关于如何在不使用xp_cmdshell的情况下使用TSQL删除.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆