Check if MSSQL is running with Command Prompt

You can check if a service is running via the command line with the sc query command.

For example, to check if MSSQL is running you might try:

sc query MSSQLSERVER

command line, search all MSSQL services:

Wmic service where (PathName like '%Binn\\sqlservr%') get caption, name, startmode, state, PathName, ProcessId

Output:

Caption                   Name              PathName                                                                                 ProcessId  StartMode  State
SQL Server (SQL2K5LOG)    MSSQL$SQL2K5LOG   "C:\App32\Microsoft SQL Server\MSSQL.4\MSSQL\Binn\sqlservr.exe" -sSQL2K5LOG              8288       Manual     Running
SQL Server (SQLEXPRESS)   MSSQL$SQLEXPRESS  "C:\App64\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS  0          Disabled   Stopped
SQL Server (SQLLOGPR)     MSSQL$SQLLOGPR    "C:\App64\Microsoft SQL Server\MSSQL10.SQLLOGPR\MSSQL\Binn\sqlservr.exe" -sSQLLOGPR      0          Disabled   Stopped
SQL Server (MSSQLSERVER)  MSSQLSERVER       "C:\App64\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe" -sMSSQLSERVER            0          Manual     Stopped

command line, search command path like Binn\sqlservr:

Wmic process where (ExecutablePath like '%Binn\\sqlservr%') get CommandLine, name, ProcessId

Output:

CommandLine                                                                  Name          ProcessId
"C:\App32\Microsoft SQL Server\MSSQL.4\MSSQL\Binn\sqlservr.exe" -sSQL2K5LOG  sqlservr.exe  8288