"Access denied" if delete files through T-SQL

  • I am trying to delete files through SQL Server 2005 T-SQL. But getting “Access denied” error. Tried both windows user and sa user to do this. Both case users were sysadmin. I can delete these files manually. So, permission is there. Is there anything else I have to do?

    Please help me to sort out this issue or please direct me to the links if already any solutions available.

    Please find the delete script below and attached screen shot of the error.

    DECLARE @lPath VARCHAR(1000)

    SET @lPath = 'D:\DB\Backup\ddd\*.txt'

    SET @lPath = 'del ' + @lPath

    EXEC xp_cmdshell @lPath

    _____________________________________________
    One ounce of practice is more important than tonnes of dreams

  • Looks like your SQL Server service account has no permission to delete.

  • Suresh B. (12/19/2011)


    Looks like your SQL Server service account has no permission to delete.

    Thanks Suresh for the reply.

    Where do I can do the changes to provide the permission?

    _____________________________________________
    One ounce of practice is more important than tonnes of dreams

  • Folder security property...

    Right click on the folder->Properties->Security->Edit->Add...

  • Suresh B. (12/19/2011)


    Folder security property...

    Right click on the folder->Properties->Security->Edit->Add...

    Suresh, Thanks TON :). It's workingggg...

    _____________________________________________
    One ounce of practice is more important than tonnes of dreams

  • Thanks for informing that it worked.

    Happy to know that your issue is resolved. 🙂

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply