The SQL Server service is not set to automatic on your development machine, because it occupies too much memory and affects the startup time.
Every time I use SQL Server, I have to go to the control panel of windows to open the service, which makes the operation complicated.
So I wrote a small script to open the SQL Server service using powershell.
Service_ SQL _server.ps1:
$ SERVICE_NAME = " MSSQL '$ sqlserver " $ Service = Get-Service $ SERVICE_NAME | Findstr $ SERVICE_NAME | Findstr " Stopped " If ([String]: isnullorempty ( $ Service ) {Write -Host $ SERVICE_NAME " The service has been started or cannot be found. " } Else {Write -Host $ SERVICE_NAME " Starting ...... " Start -Service $ SERVICE_NAME Write -Host $ SERVICE_NAME " Started ...... " } [System. Threading. Thread] : Sleep (3000)
Service_ SQL _server.bat:
Powershell D: \ project \ powershell \ service_ SQL _server.ps1sleep5