Brad’s Sure Guide to SQL Server Maintenance Plans- P18 pdf

5 277 0
Brad’s Sure Guide to SQL Server Maintenance Plans- P18 pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

Chapter 4: Task Scheduling 86 task will not be created. This means the task will not run automatically and we'll need to run it manually instead. Scheduling using the Maintenance Plan Designer If you create an "on demand" task, you can always add a schedule at a later time using the Maintenance Plan Designer. Since our goal, generally, is to automate our maintenance tasks, not to perform them manually, we'll be creating a schedule for the tasks covered in this book. Job Schedule Properties When a task is assigned to a schedule, that task is referred to as a "job," in light of the fact that the task will be executed as a job from within the SQL Server Agent. In this section, we'll discuss the logistics of creating a job schedule. In order to begin this process, click on the Change button shown in Figure 4.1, and the Job Schedule Properties screen, shown in Figure 4.3, will appear. Let's take a closer look at each section of this screen, starting at the top. Chapter 4: Task Scheduling 87 Figure 4.3: The "Job Schedule Properties" screen can be a little overwhelming. Job Schedule Name and Type The first thing you will notice is that the name of this job schedule has been filled out for you, using a combination of the Maintenance Plan name and the name of the task being scheduled. In this example, it is "User Database Maintenance Plan.Check Database Integrity," as shown in Figure 4.4. Figure 4.4: Notice that this schedule has been given a default name. I don't see any reason to change this name, as the naming scheme makes a lot of sense. Next to the schedule name is a grayed out box, titled Jobs in Schedule. This feature is not relevant to Maintenance Plan scheduling, and you can ignore it. Chapter 4: Task Scheduling 88 The redundant Jobs in Schedule button You're probably wondering why, if the button is not used, it appears on the screen. This particular screen is shared code that is used by other parts of SSMS. The developers of SSMS decided to reuse the same scheduling code instead of creating additional code, specifically designed for the Maintenance Plan Wizard. The result is a button we don't need, along with a few other options we don't need either, as we will soon see. In the next part of the screen, you must specify the Schedule type. The default option is Recurring, as shown in Figure 4.5, and is the one you should choose, as the goal of a Maintenance Plan is to create recurring jobs that run specific tasks. Figure 4.5: You have to specify when the job is to occur, and whether it is enabled or not. The other options, while they could be used, are really designed for other purposes (remember, this is shared code) and not for the Maintenance Plan Wizard. In fact, using any of the options other than Recurring could easily get you into trouble, as they are not time based, and thus you cannot schedule a specific time to run a task. By default, the Enabled checkbox, to the right of Schedule type, is selected indicating that the job schedule is enabled and active. You should accept this default and leave the box selected. If, for some reason, you want to temporarily turn off a scheduled task after a Plan has been created, you can do so using the Maintenance Plan Designer, which is discussed in Chapter 16 and onwards. Job Frequency The next part of the Job Schedule Properties screen is called Frequency, as shown in Figure 4.6. The appearance of this screen varies depending on the option selected for Occurs. By default, this is Weekly, which is a little deceiving. When I think of weekly, I think of once a week, but that is not what this option means. It means that you have the option to select which days in a week you want a job to run. Only Sunday is selected by default, but you can choose any day of the week, and as many of them as you want. Chapter 4: Task Scheduling 89 Figure 4.6: You must choose how often a task is to be executed. In some cases, you may not want to perform a task on a weekly basis, but every two weeks, or every four weeks. If this is the case, you can change this behavior by setting the value for Recurs every. The default value is 1 (weekly) but you can increase it to 2 for every two weeks, and so on. In most cases, you will find it simplest to use 1 as the Recurs every value; otherwise it gets hard to keep track of your schedule. If you choose Daily, instead of Weekly, for Occurs then you'll notice that the screen changes slightly in appearance, as shown in Figure 4.7. Figure 4.7: The Daily option allows you to select how often daily really is. The Daily option also gives the impression that the job is to run once a day, but that is not the case. In fact, you can schedule jobs to run as often as want, on a daily basis, as you'll see when we reach the Daily Frequency section of the screen, shortly. The Recurs every option works just as described previously. The default value of 1 indicates that the job will run every day; a value of 2 means every other day, and so on. Again, I recommend you keep it simple and leave Recurs every at its default value of 1. If you choose the final option, Monthly, the screen changes once again, as shown in Figure 4.8. Figure 4.8: The Monthly options gives you more options that you can probably find good uses for. Chapter 4: Task Scheduling 90 The Day option has two configurable values. The first value refers to the day of a month. For example, if the value is 1, then the job will occur on the first day of every month, if the value is 2, it would mean that job occurs on Day 2 of every month, and so on. The second value refers to the month. A value of 1 means the job is to run every month, if the value is 2, then the job runs every other month, and so on. This option can get complicated very quickly. Rather than use the Day option, you can, instead, use the The option to specify job frequency, as shown in Figure 4.9. Figure 4.9: The "The" option gives you even more choices. The default setting specifies that the job will occur on the first Monday of every month. If you change "first" to "second," this would mean the second Monday of every month, and so on. You can also change the day of the week, and for which months. Again, all of this gets complicated very quickly, and I suggest you keep things as simple as possible, and avoid using this option. Daily Frequency The next option on the Job Schedule Properties screen is Daily Frequency, as shown in Figure 4.10. Figure 4.10: The Daily frequency option allows us to schedule a job to occur more than once a day. Didn't we just see a daily option in the Frequency section of the screen? Yes, we did, but this Daily frequency option means something entirely different. It refers to when and how often on the day(s) selected in the Frequency section the task will occur. The Occurs once at option allows us to schedule the time of a day the task is to run once. By default, a task is scheduled to occur once a day at 12 a.m. . always add a schedule at a later time using the Maintenance Plan Designer. Since our goal, generally, is to automate our maintenance tasks, not to perform them manually, we'll be creating. Properties When a task is assigned to a schedule, that task is referred to as a "job," in light of the fact that the task will be executed as a job from within the SQL Server Agent. In this section,. any reason to change this name, as the naming scheme makes a lot of sense. Next to the schedule name is a grayed out box, titled Jobs in Schedule. This feature is not relevant to Maintenance

Ngày đăng: 04/07/2014, 23:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan