The sqlservr executable is the program that runs when SQL Server is started. You can use the sqlservr
executable to start SQL Server from a command prompt. When you do that,
all the startup messages are displayed at the command prompt, and the
command prompt session becomes dedicated to the execution of SQL Server.
Caution
If you start SQL Server
from a command prompt, you cannot stop or pause it by using SSMS,
Configuration Manager, or the Services applet in the Control Panel. You
should stop the application only from the command prompt window in
which SQL Server is running. If you press Ctrl+C, you are asked whether
you want to shut down SQL Server. If you close the command prompt
window in which SQL Server is running, SQL Server is automatically shut
down.
The syntax for the sqlserver utility is as follows:
sqlservr [-sinstance_name] [-c] [-dmaster_path] [-f]
[-eerror_log_path] [-lmaster_log_path] [-m]
[-n] [-Ttrace#] [-v] [-x] [-gnumber] [-h]
Most commonly, you start SQL Server from the command prompt if you need to troubleshoot a configuration problem. The –f
option starts SQL Server in minimal configuration mode. This allows you
to recover from a change to a configuration setting that prevents SQL
Server from starting. You can also use the –m option when you need to start SQL Server in single-user mode, such as when you need to rebuild one of the system databases.
SQL Server functions when
started from the command prompt in much the same way as it does when it
is started as a service. Users can connect to the server, and you can
connect to the server by using SSMS. What is different is that the SQL
Server instance running in the command prompt appears as if it is not
running in some of the tools. SSMS and SQL Server Service Manager show
SQL Server as being stopped because they are polling the SQL Server
service, which is stopped when running in the command prompt mode.
Tip
If you simply want to start the SQL Server service from the command prompt, you can use the NET START and NET STOP
commands. These commands are not SQL Server specific but are handy when
you want to start or stop SQL Server, especially in a batch file. The
SQL Server service name must be referenced after these commands. For
example, NET START MSSQLSERVER starts the default SQL Server instance.