Posts

Showing posts from March, 2012

How to delete old backup files by script.

Extended procedure 'xp_delete_file ' is used for to delete the backup files in the server.
We need to specify the file type selected ((0 = FileBackup,1=File Report),folder path(trailing slash), file extension which needs to be deleted (N'bak'),date(prior whichtodelete) and folder flag level((1 = include files in first subfolderlevel,0=not) as like below in the Sql Server Management Studio.
EXECUTEmaster.dbo.xp_delete_file 0, N’D:\SQLBackup',N'BAK',N'06/07/2011 10:18:49',1
By running above script, we can able to delete the old backup files prior to the above specified date.