日期:2014-05-17  浏览次数:20419 次

有没有sql语句可以删除文件的?
有没有sql语句可以删除文件的?例如删除sqlserver数据库所在服务器的'c:\a.txt'

------解决方案--------------------
exec master.dbo.xp_cmdshell 'del c:\a.txt'
------解决方案--------------------
USE master
GO
sp_configure 'show advanced options', 1 
GO
RECONFIGURE WITH OVERRIDE
GO
sp_configure 'xp_cmdshell', 1 
GO
RECONFIGURE WITH OVERRIDE
GO 

EXEC sys.xp_cmdshell 'del c:\1.txt'
 
USE master
GO
sp_configure 'xp_cmdshell', 0 
GO
RECONFIGURE WITH OVERRIDE
GO
sp_configure 'show advanced options', 0 
GO
RECONFIGURE WITH OVERRIDE
GO