我最近安装了SQL Server 2019,并且在启动时占用了不错的3 GB或RAM。
我只是在家中将其用于个人用途,因此已将其关闭。
我想知道是否有一种方法可以在PowerShell
或CMD
中写一个脚本:
SQL Server (MSSQLSERVER)
SQL Server (MSSQLSERVER)
您可以创建脚本来启动服务器(例如批处理文件或PowerShell),然后运行SSMS.exe。
您也可以在以下位置启动SQL Server引擎:
命令提示符
net start "SQL Server (MSSQLSERVER)"
PowerShell
# Get a reference to the ManagedComputer class.
CD SQLSERVER:\SQL\computername
$Wmi = (get-item .).ManagedComputer
$DfltInstance = $Wmi.Services['MSSQLSERVER']
# Display the state of the service.
$DfltInstance
# Start the service.
$DfltInstance.Start();
# Wait until the service has time to start.
# Refresh the cache.
$DfltInstance.Refresh();
# Display the state of the service.
$DfltInstance
# Stop the service.
$DfltInstance.Stop();
# Wait until the service has time to stop.
# Refresh the cache.
$DfltInstance.Refresh();
# Display the state of the service.
$DfltInstance
关于docs的更多详细信息。