• I am bad at writing articles but the easiest I think is to add a step next to backup command in job schedule. Add this command to next step and it will take care of deleting old files. All you have to change is the number you want to retrieve.

    I am using this on all server across board on 361 servers for last two years and never had a problem.

    Command:

    DECLARE @currentdate datetime

    DECLARE @olddate datetime

    set @currentdate = CURRENT_TIMESTAMP

    set @olddate = @currentdate - 1 -- Change number here depending how many days of backup file you want to retain on server.

    -- Add below line for each database.

    EXECUTE master.dbo.xp_delete_file 0,N'G:\<Backup file path>\<your database name>',N'bak',@olddate,1

    EXECUTE master.dbo.xp_delete_file 0,N'G:\<Backup file path>\<your database name>',N'bak',@olddate,1

    -- Backup file path example : G:\Program Files\Microsoft SQL Server\MSSQL\MSSQL.1\Backup\<your database name>

    SQL DBA.