Chapter 17: Configuring Maintenance Tasks Using the Designer 206 Figure 17.3: We have seen this database selection screen many times before. For the purposes of this demo, select the AdventureWorks database, and then click on OK. The Check Database Integrity Task screen should now look as shown in Figure 17.4. Figure 17.4: A specific database, AdventureWorks, has been selected, although we can't see the database name from this screen. Now that a database selection has been made, the Include indexes option is available, which is checked by default, and means that both tables and indexes will be included in the check. As discussed in Chapter 5, this makes the task a little more resource-intensive but, in most cases, I recommend you leave it checked. Chapter 17: Configuring Maintenance Tasks Using the Designer 207 You have probably noticed a button on this screen that you have not seen before, namely the View T-SQL button. When you click on it, you get to see (but not modify) the T-SQL code that will be run when the task executes as currently configured (see Figure 17.5). Figure 17.5: The Maintenance Plan Wizard allows you to view the T-SQL that will be run for each maintenance task. If you're unfamiliar with T-SQL then this screen isn't much use to you, but most DBAs like to understand what T-SQL will be executed when they run a given task. Notice, however, the warning under the T-SQL code, indicating that the T-SQL you see may not be the exact T-SQL that is actually executed, due to the potential inclusion of further conditional logic that could alter the T-SQL that is executed, or mean that it is not executed at all. We'll cover this in more detail in Chapter 18, but suce to say that the only way to really know what T-SQL was run for a particular task is to check the text file report that is created after a Maintenance Plan executes (see Chapter 3). When you return to the design surface, you'll see that the Check Database Integrity task looks slightly different, as shown in Figure 17.6. Figure 17.6: This task is configured and ready to execute. First, the text underneath the name of the task now reflects our chosen configuration settings. Second, the red circle with the white "x" is also gone, indicating that this task has been configured and is ready to run. This concludes our brief discussion of the Check Database Integrity task, and we still have ten more to go. Chapter 17: Configuring Maintenance Tasks Using the Designer 208 Rebuild Index Task As discussed in Chapter 7, to which you should refer for full details, the Rebuild Index task will physically drop and rebuild any designated indexes, as a means to removing logical fragmentation and wasted space. As always, the first step in configuring the Rebuild Index task in the Designer is to drag it from the Toolbox and drop it onto a design surface, at which point the Rebuild Index Task box appears and the task is ready to be configured, as shown in Figure 17.7. Figure 17.7: The Rebuild Index Task on the design surface. To configure the Rebuild Index task, double-click on it (or right-click and select edit) to bring up its configuration screen, as shown in Figure 17.8. Figure 17.8: The options for the Rebuild Index Task for the Maintenance Plan Designer and the Maintenance Plan Wizard are identical. Chapter 17: Configuring Maintenance Tasks Using the Designer 209 In Figure 17.8, I've already selected a specific database to be the target of the Rebuild Index task, so that all other options are activated. Aside from the previously discussed Connection and View T-SQL buttons, these options are identical to those shown and described in the Configuring the Rebuild Index Task section of Chapter 7, and so will not be covered again here. When you've configured the task as required, click OK, and the Rebuild Index Task box will reappear, displaying the specified configuration settings. Reorganize Index Task As discussed in Chapter 8, to which you should refer for full details, the Reorganize Index task is a much "gentler" version of the Rebuild Index task. It does not physically drop and rebuild the index but, instead, reduces logical fragmentation and minimizes unused space by reorganizing the leaf level pages. Figure 17.9 shows the task box for the Reorganize Index task is its unconfigured state. Figure 17.9: The Reorganize Index Task on the design surface. Double-click on the task box to bring up the configuration screen, shown in Figure 17.10. Figure 17.10: The Reorganize Index Task configuration options. Chapter 17: Configuring Maintenance Tasks Using the Designer 210 Again, these options are identical to those shown and described in the Configuring the Reorganize Index Task section of Chapter 8, and so will not be covered again here. When you've configured the task as required, click OK, and the Reorganize Index Task box reappears, displaying the specified configuration settings. Update Statistics Task As described in Chapter 9, to which you should refer for full details, the UPDATE STATISTICS task causes the UPDATE STATISTICS command to be executed against all of the tables in the databases you select, ensuring that all index and column statistics are current, and so that the query optimizer has all the information it needs to determine the optimal execution plan for a given query. Figure 17.11 shows the task box for the Reorganize Index task, as dropped onto a design surface in its unconfigured state. Figure 17.11: The Update Statistics Task on the design surface. Double-click on the task box to bring up the configuration screen, shown in Figure 17.12. . Configuring Maintenance Tasks Using the Designer 207 You have probably noticed a button on this screen that you have not seen before, namely the View T -SQL button. When you click on it, you get to see. T -SQL code that will be run when the task executes as currently configured (see Figure 17.5). Figure 17.5: The Maintenance Plan Wizard allows you to view the T -SQL that will be run for each maintenance. with T -SQL then this screen isn't much use to you, but most DBAs like to understand what T -SQL will be executed when they run a given task. Notice, however, the warning under the T -SQL code,