Search code examples
sqlsql-serversql-server-2005xp-cmdshell

Unable to delete zip files from DB server location using xp_cmdshell


I have a Zip file created and I am unable to delete it using the below command.

xp_cmdshell 'rm "F:\EXIS\Reports\Individual.zip"'

It gives an error saying File not found, when I can actually see the file.

I tried using xp_cmdshell 'del "F:\EXIS\Reports\Individual.zip"'

But, this asks for a confirmation, which I actually cannot input.

Please suggest if anything,

Thanks.


Solution

  • The message is more generic in the sense the file is not found with the current credentials of SQL Server process while accessing the indicated location.

    I suspect it is a problem of rights, so please assure the SQL Server proecess has rights to delete file in that location. An alternative suggestion is to perform a "dir" on that location.