I want to delete files from backup activities using xp_delete_files, I created a new maintenance plan to delete *.bak and *.trn files.
Both doesn't work and no error message is generated.
The T-SQL statement being made is:
EXECUTE master.dbo.xp_delete_file 0,N'D:\Backup\iWMC',N'bak',N'2010-05-11T12:48:38'
When I run it in a query window using my own account it fails as well without a message.
- that the files to be deleted are a result of an backup (the first 0)
- the path is correct no trailing \ (i tried a trailing \ and that doesn't work either)
- file extension doesn't has a . in it (i tried a leading . and that doesn't work either)
- the date contains a T and is of nchar type
The instance is version 9.0.3080 SP2 standard edition on a 64 bit platform.
Answer by ThomasRushton ·
The joys of using undocumented commands.
However, there is some useful information here: http://sqlblog.com/blogs/andy_leonard/archive/2009/03/11/xp-delete-file.aspx - this link shows a further parameter that your code doesn't have. Perhaps this is the problem?