Share via


Maintenance Cleanup Task (Maintenance Plan)

Use the Maintenance Cleanup Task to remove old files related to maintenance plans, including text reports created by maintenance plans and database backup files.

Note

In contrast to earlier versions of the Maintenance Cleanup task, the SQL Server 2005 version of the task does not automatically delete files in the subfolders of the specified directory. This feature reduces the possibility of a malicious attack that uses the Maintenance Cleanup task to delete files. If you want to delete files in first-level subfolders, you must select Include first-level subfolders.

Important

The addition of the Hour interval in cleanup tasks has implications when you are running multiple version of SQL Server 2005. If you create a task that has an interval of hours, and then try to run that task on either the release version of SQL Server 2005 or SQL Server 2005 Service Pack 1, you will get a different interval. If you edit the task using the earlier versions of the tools, an error message will appear.

Options

  • Connection
    Displays the current connection.
  • New
    Create a new server connection to use when performing this task. The New Connection dialog box is described below.
  • Backup files
    Delete backup files.
  • Maintenance Plan text reports
    Delete text reports of previously run maintenance plans.
  • Delete specific file
    Delete the specific file provided in the File name box.
  • File name
    Path and name of the file to be deleted.
  • Search folder and delete files based on an extension
    Delete all files with the specified extension in the specified folder. Use this to delete multiple files at once, such as all backup files with the .bak extension, in the Tuesday folder.
  • Folder
    Path and name of the folder containing the files to be deleted.
  • File extension
    Provide the file extension of the files to be deleted. Do not include the "." For example, to search for backup files, type bak or BAK.
  • Include first-level subfolders
    Delete files with the extension specified for File extension from first-level subfolders under Folder.
  • Delete files based on the age of the file at task run time
    Specify the minimum age of the files that you want to delete by providing a number, and unit of time in the Delete files older than the following box.
  • Delete files older than the following
    Specify the minimum age of the files that you want to delete by providing a number, and unit of time (Hour, Day, Week, Month, or Year). Files older than the time frame specified will be deleted.
  • View T-SQL
    View the Transact-SQL statements performed against the server for this task, based on the selected options.

    Note

    When the number of objects affected is large, this display can take a considerable amount of time.

New Connection Dialog Box

  • Connection name
    Enter a name for the new connection.
  • Select or enter a server name
    Select a server to connect to when performing this task.

  • Select to view the list of available servers.
  • Enter information to log on to the server
    Specify how to authenticate against the server.
  • Use Windows integrated security
    Connect to an instance of the SQL Server Database Engine with Windows Authentication.
  • Use a specific user name and password
    Connect to an instance of the SQL Server Database Engine using SQL Server Authentication. This option is not available.
  • User name
    Provide a SQL Server login to use when authenticating. This option is not available.
  • Password
    Provide a password to use when authenticating. This option is not available.

See Also

Other Resources

Maintenance Plans

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

15 September 2007

New content:
  • Added the Important note about the Hour interval.

14 April 2006

New content:
  • Added description of the new option Include first-level subfolders. This option is available in Service Pack 1.