Thursday, March 22, 2012

How to start SQL server from command line, and what happens next

If You want to start SQL Server from command line, go to the desired SQL Server binn folder:

cd \Program Files\Microsoft SQL Server\MSSQL10_50.1\MSSQL\Binn

If there are more SQL Servers installations on a machine, there could a problem if You do not go to the desired location, because there would be more sqlserver.exe instances.

You could start one SQL Server instance from another SQL Server binn folder(with different SQL Server instance name), but that can cause unknown problems.

So, when I go to the desired binn folder, execute

sqlserver -s instancename

What's happening next?

In Windows registry, there is following path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server

and there is following variable:
InstalledInstances

with instance names which are installed on Your machine. One of these instances has the same name as You entered in previous command which starts SQL Server .

For every of these instances there is a adequate registry path.

For example, one of the instances can have a name SQLEXPRESS, there will be following registry path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS

where this last SQLEXPRESS is the name of the instance.

Under this registry key there is a key named MSSQLServer -> Parameters where are the parameters used in process of starting SQL Server instance.

By default there should be 3 parameters:
- d - which represents the path to the master database data file
- l - which represents the path to the master database log file
- e - which represents the path to the error log

Path to the master database is essential because it is the first database which is brought up online, and in this database are data needed for all other database which should be started.


No comments:

Post a Comment