查找含有sql的服务名,分为SERVICE_NAME服务名和DISPLAY_NAME显示名
C:\Windows\system32>sc query |findstr "SQL"
DISPLAY_NAME: SQL Server Integration Services 10.0SERVICE_NAME: MSSQLFDLauncher
DISPLAY_NAME: SQL Full-text Filter Daemon Launcher (MSSQLSERVER)
SERVICE_NAME: MSSQLSERVER
DISPLAY_NAME: SQL Server (MSSQLSERVER)
SERVICE_NAME: MSSQLServerOLAPService
DISPLAY_NAME: SQL Server Analysis Services (MSSQLSERVER)
DISPLAY_NAME: SQL Server Reporting Services (MSSQLSERVER)
SERVICE_NAME: SQLWriter
DISPLAY_NAME: SQL Server VSS Writer
查看具体服务名的服务状况
C:\Windows\system32>sc query MSSQLSERVER
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
关闭或启动MSSQLSERVER服务
C:\Windows\system32>sc stop/start MSSQLSERVER
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x1
WAIT_HINT : 0xea60
查看服务sid具体状态
C:\Windows\system32>sc showsid MSSQLSERVER
名称: MSSQLSERVER
服务 SID: S-1-5-80-3880718306-3832830129-1677859214-2598158968-1052248003
状态: 活动
查看服务的具体配置信息
C:\Windows\system32>sc qc MSSQLSERVER
[SC] QueryServiceConfig 成功
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -sMSSQLSERVER
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : SQL Server (MSSQLSERVER)
DEPENDENCIES :
SERVICE_START_NAME : NT AUTHORITY\NETWORKSERVICE
查看依赖MSSQLSERVER服务的服务
C:\Windows\system32>sc enumdepend MSSQLSERVER
[SC] EnumDependentServices: 读取的项 = 1
SERVICE_NAME: SQLSERVERAGENT
DISPLAY_NAME: SQL Server 代理 (MSSQLSERVER)
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0