SQL 2005 Database Management Plans Overview STI recmmends that users create database maintenance plans fr Micrsft SQL 2005 t maintain the integrity f the system s database. Database maintenance plans are cmprised f autmated jbs which may be scheduled t run unattended daily, weekly r mnthly. This dcument prvides instructins n creating and using a database maintenance plan. Creating Database Maintenance Plan A database maintenance plan is simply a set f tasks that will be autmatically perfrmed n yur SQL Server databases. This set f tasks will lessen the burden n the administratr by autmating essential maintenance tasks. These tasks, which include data integrity checks, backup, and database ptimizatin, will keep the database running at tp efficiency. Creating a maintenance plan differs a little frm SQL 2000 t SQL 2005. Users wh are ging t use new Maintenance Plan features are strngly advised t install the SQL Server 2005 Service Pack 2 first. In rder t create a new maintenance plan in Management Studi, cnnect t the target server using Windws Authenticatin and perfrm the steps that fllw. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 1
Open SQL Server Management Studi. Right-click n the Maintenance Plan flder in Object Explrer. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 2
Select New Maintenance Plan and enter a descriptive name fr the plan. A Maintenance Plan design panel will appear n the right, and a tlbx with available Maintenance Plan Tasks will be displayed n the left. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 3
Click n the Cnnectin buttn t verify that the current cnnectin uses Windws Authenticatin (recmmended by Micrsft). Currently the cnnected Windws user will becme the wner f the jb created by this maintenance plan. The first step in creating a database r transactin lg backup is t drag and drp Back up database task frm the tlbx t the design panel. Then duble-click n that item t set the fllwing necessary prperties: Click n the drp-dwn field t bring up the database selectin windw. Fr Backup type, chse Full. Under Destinatin Parameters, select t back up t Disk. Make sure that the Create a backup file fr every database ptin is selected and als ensure that the Create a sub-directry fr each database bx is checked. Yu may use the default destinatin flder r specify yur wn. Fr Backup file extensin, make sure that the value listed is bak, withut a leading dt denting the file extensin. Check the Verify backup integrity bx. Having verified the task prperties, click OK t save. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 4
Scheduling the Database Maintenance Plan T create a schedule fr this plan, click n the ellipsis buttn, lcated t the right f the Schedule field. Set the necessary parameters in the Jb Schedule Prperties windw. Schedule Name will be defaulted t <maintenance_plan_name>-schedule and may be mdified if necessary. Click OK t save this schedule. Nte: When the user clicks n the Lgging buttn, the Reprting and Lgging windw will appear. This screen is similar t the SQL 2000 Reprting tab. The default flder fr the backup may be mdified. The user may als chse between the Create a new file ptin, which will create a new lg file named <maintenance_plan_name> _yyyymmddhhmm.txt fr every cmpleted jb; r the Append t file ptin (in this case, the user must name the lg file). An ptin is als available t Send an e-mail t the peratr. In rder t delete bslete backup files, an additinal Maintenance Cleanup Task must be inserted and cnfigured. Drag and drp this task int the design panel and duble-click n it t set the prperties: Cnnectins: Keep the default Lcal server cnnectin. Delete files f the fllwing types Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 5
Chse the Backup files ptin. File lcatin: Select Search flder and delete files based n an extensin. Prvide the same full path t the backup flder that was used n the Back up database task. The file extensin shuld be the same as that used in Back up database task: bak fr the database backup files r trn fr the transactin lg backup files (bth shuld be entered withut the leading dt used t indicate a file extensin). If a separate directry was created fr each database in Back up database task, the user may als check the Include first-level subflders bx. Under File age:, check Delete files based n the age f the file at task run time and set the Delete files lder than the fllwing ptin. Click n File Save As t save the plan. As a result, a new jb, with the same name as the maintenance plan name, has been created. Bth the plan and the jb will be listed in the Object Explrer panel. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 6
T test these plans/jbs, the user may right-click n the plan icn in Object Explrer and select Execute frm the drp-dwn menu, r right-click directly n the jb and select Start Jb at Step, as applicable. Checking the Results The plan/jb results will be stred in the msdb database and in the file specified in the plan Lgging prperty. If the Lg extended infrmatin bx was checked in the Reprting and Lgging windw during maintenance plan creatin, the detailed infrmatin will be stred in bth the lg file and the msdb.db.sysmaintplan_lgdetail table. If this bx was nt checked and the jb status is Succeeded, there will be n details prvided in the lg file r in the msdb.db.sysmaintplan_lgdetail table. Hwever, if any f the tasks failed, the details will be available in this lcatin. The user may als check the results in Management Studi by right-clicking n the plan r jb icn and selecting View Histry frm the drp-dwn menu, then expanding the recrd fr a failed plan/jb. Quick Ref Guide STI_1007081433 SQL 2005 Database Management Plans 7