In two previous articles (Part 1 and Part 2), I've looked at some of the details surrounding starting and stopping SQL. In a lot of ways it's simple, but there are times when it's not. Especially if you're doing something for the first time and feel like you're in over your head! Today we'll a look at command line parameters, checkpointing and recovery, and a few miscellaneous items.
SQL supports a range of command line parameters, some documented and some not. There are three that are always used to set the locations of master.mdf, master.ldf, and the errorlog. Strangely (to me anyway) these switches are saved in the registry rather than as part of the service configuration. Note the second image where I'm passing in the "-m" parameter which tells SQL to start in SQL user mode. Note that I did this as a test only, this is not a recommended configuration!
Figure 1
Figure 2
Figure 3
During a standard shutdown SQL will issue a checkpoint in each database. Let's define a checkpoint as having written all dirty pages at that point to disk, which means guaranteed recovery to that point. Running the checkpoint takes some amount of time, based on the recovery interval you've set, how many dirty pages exist, how busy the disks are, etc. When you restart the service, if
you look in the log you'll sometimes see comments about transactions being rolled forward or rolled back. These are normal entries. The key point to remember is that you'll always wind up in a transactionally consistent state. In other words, don't worry!
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
One common question I get is 'how do you know when the service is stopped'? The cleanest way I've seen is to open Task Manager and wait for the sqlservr.exe entry to disappear. On systems with a lot of memory this can take several minutes.
Figure 10
Figure 11
Syntax
scm [-?]
-Action {1 | 2 | 3 | 4 | 5 |
6 | 7}
-Service service_name
[-Server server_name]
[-Pwd sa_password]
[-StartupOptions startup_option [ ...n] ]
[-ExePath exe_file_path]
[-SvcStartType {1 | 2}]
[-SvcAccount service_account]
[-SvcPwd service_password]
[-Dependencies service_name_dependency [;...n]
]
I thought three articles would be enough, but I can see where it will take at least one more. Next time we'll look at a couple tips that will save you some headaches in production.