Autorestart if service stops SQL Server 2014 Express

637 views Asked by At

I've just installed SQL Server 2014 Express, last night the service stopped and didn't restart. Searching online I found only the option on SQL Server Agent to auto restart if the service stops, which is not available on SQL Server Express edition.

Is there any way to set up autorestart if service fails or stops?

I'm on a Windows Server 2012 R2 server.

1

There are 1 answers

0
yagmoth555 On

Please do a scheduled task that run a script like that;

for /F "tokens=3 delims=: " %%H in ('sc query "mssql" ^| findstr "        STATE"') do (
  if /I "%%H" NEQ "RUNNING" (
   net start "mssql"
  )
)

Please just validate the servicename for your sql instance.