# Database Discussions > Microsoft SQL Server 2008 >  Issues using xp_delete_file

## ezecastle

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'

----------


## rmiao

Did you run it as sql job? Does sql id ou use have os delete file permission on the server?

----------


## ezecastle

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.

----------


## rmiao

Both servers have same sql service account?

----------


## ezecastle

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. :EEK!:

----------

