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

解决方案 »

  1.   

    exec master.dbo.xp_cmdshell 'del c:\a.txt'
      

  2.   

    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