Results 1 to 5 of 5

Thread: Issues using xp_delete_file

  1. #1
    Join Date
    Aug 2004
    Posts
    188

    Issues using xp_delete_file

    When I run the script bellow on my local sql server instance it works just fine. I can backup master then It will delete without any issues.

    But... When I go to run this on my production server the backup is created but not deleted. I'm not seeing any errors. The SQL versions are the same SQL 2008 sp1.

    Any ideas?
    Thanks.

    BACKUP DATABASE model TO DISK = 'C:\model.bak'


    WAITFOR DELAY '00:00:10'


    EXECUTE master.dbo.xp_delete_file 0,
    N'C:\',
    'bak',
    '2010-01-01T00:00:00'

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Did you run it as sql job? Does sql id ou use have os delete file permission on the server?

  3. #3
    Join Date
    Aug 2004
    Posts
    188
    I run it both ways, as a job and in a query window. I'm able to manually delete the files. I'm an admin on both servers and I try it while logged in as "sa" So I'm assuming I can delete.

    It's strange because on 2 identical sql 2008 installs one will work but the other will not. I can't figure it out.

    Thanks for your help.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Both servers have same sql service account?

  5. #5
    Join Date
    Aug 2004
    Posts
    188
    That was it! Thanks, I gave the correct permissions to the account that's set to start SQL Server and it deleted the file without any issues.

    Thanks for your help, that was driving me nuts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •