您的位置:首页 > 数据库

在SQL Server中使用SQL命令删除文件

2014-06-23 20:49 453 查看
Sql代码

exec master.dbo.xp_cmdshell'del
D:\test.txt'

exec master.dbo.xp_cmdshell 'del D:\test.txt'


在SQL Server中,这个语句可以用来删除D盘下的test.txt文件。

如果'xp_cmdshell'没有启用,可以使用下列语句启用'xp_cmdshell':

Sql代码

exec sp_configure
'show advanced options', 1;
reconfigure;
exec sp_configure 'xp_cmdshell',1;

reconfigure;

exec sp_configure 'show advanced options', 1; reconfigure; exec sp_configure 'xp_cmdshell', 1; reconfigure;


其中,'1' 表示启用,'0' 表示停用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: