Task Scheduler Problem Starting MSSQLSERVER
-
09-06-2019 - |
Question
I am trying to create a Task Scheduler task to start my SQL Server 2005 instance every morning, because something stops it every night. This is a temporary solution until I can diagnose the stoppage.
I created a task to run under my admin user, and to start the program, cmd with the arguments /c net start mssqlserver. When I manually run the command, in a console under my admin user, it runs, but when I try to manually execute the task, it logs the following message, and the service remains stopped:
action "C:\Windows\system32\cmd.EXE" with return code 2.
Any suggestions?
Solution
I would recommend opening the Services MMC snap-in (just run services.msc), finding the service and modifying the properties of the service to restart automatically when the service fails.
- Open the Services MMC snap-in (run services.msc)
- Locate the service. If you installed a default instance of SQL Server 2005 that would be "SQL Server (MSSQLSERVER)". If you installed a named instance the name would be in the parenthesis.
- Right-click on the service and select "Properties".
- Switch to the "Recovery" tab.
- Set the options for first, second and subsequent failures as desired.
- Click "OK".
And John Dyer is also right about looking in the Windows Event logs for details on why SQL Server stopped (run eventvwr.exe).
OTHER TIPS
Use the NET command:
To start a service, type: net startservice
To stop a service, type: net stopservice
To pause a service, type: net pauseservice
To resume a service, type: net continueservice
See this Microsoft article on additional details: Microsoft Article
In addition I would look at the Windows Event logs (Application and System) for details as to why SQLServer is stopping in the first place.