13
I'm trying to write some SQL that will delete files of type '.7z' that are older than 7 days.
Here's what I've got that's not working:
DECLARE @DateString CHAR(8)
SET @DateString = CONVERT(CHAR(8), DATEADD(d, -7, GETDATE()), 1)
EXECUTE master.dbo.xp_delete_file 0,
N'e:\Database Backups',N'7z', @DateString, 1
I've also tried changing the '1' at the end to a '0'.
This returns 'success', but the files aren't getting deleted.
I'm using SQL Server 2005, Standard, w/SP2.