Managing Database Maintenance

SQL Server provides a host of database maintenance commands. Fortunately, it also provides the DBA with ways to schedule maintenance tasks.

Planning Database Maintenance

Database maintenance plans include the following routine tasks:

  • Check database integrity.
  • Perform index maintenance.
  • Update database statistics.
  • Perform database backups.

These maintenance tasks can be automated and scheduled using SQL Server Agent service. Once created, the maintenance plans (and subplans) are scheduled in SQL Server Agent as jobs.

Maintenance Plan

Following are two ways to create a Maintenance Plan:

  • Maintenance Plan Wizard: Used to quickly create a basic maintenance plan. This enables you to choose one of the predefined typical maintenance tasks, such as performing database backup, rebuilding indexes, updating statistics, checking data integrity and cleaning up history and backup files.. It does not enable you to add any custom tasks.
  • Maintenance Plan Design Surface: Used to design maintenance plans with more flexibility. This enables you to create a workflow of typical maintenance tasks and create custom maintenance tasks using T-SQL scripts. It also enables extended logging, which can prove to be useful for troubleshooting purposes.

All the maintenance plans appear in the Management\Maintenance Plans folder of SQL Server Management Studio. To launch the Maintenance Plan Wizard, right-click the Maintenance Plans folder, and choose Maintenance Plan Wizard. Follow ...

Get Microsoft SQL Server 2012 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.