locked
Automating SQL Services Start/Stop RRS feed

  • Question

  • I have slow computer and I'm using SQL server 2008 Standard edition and I use all services full text search, reporting, analysis and Agent when I develop but the same DevBox use a personal computer when I'm not developing.

    What I want to do is stop these heavy services when I'm not developing and I know it can be done manually everytime by "Services Control Manager". Is there anyway to automate this process to start and stop by writing a single command. I hope Windows Power Shell may support this but I dont know if that would be possible as I dont know Power Shell.

    Can some body let me if this is possible by Power Shell so I can dig more into it or by any other means?

    Thanks.
    Rendezvous
    Sunday, March 22, 2009 10:59 PM

Answers

  • Hello Kaleem,

    Follow the steps mentioned in this link.

    http://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/

    Thanks,
    Prashanthi
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 5:19 AM
  • You can use Net Stop in a batch file to do this.  For instance:

    NET STOP "SQL Server (MSSQLSERVER)"
    NET STOP "SQL Server Agent (MSSQLSERVER)"

    Here's what you do:
        - Create a new text file.
        - Write out your NET STOP commands.
        - Rename the file from a .txt extension to a .bat extension
        - Run it any time you need to stop the services.

    You can do the same to start them back up again, but use NET START instead of NET STOP.

    Does this help?


    Aaron Alton | thehobt.blogspot.com
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 5:21 AM
  • Thanks Prashanthi and Aaron!!

    Both of above are nearly identical. However using the first one I was only able to stop a default instance whereas with second one using double quotes I was also able to both default and named instance(I have two instances running side by side). Also I would like to know what will be the right order to start the services among SQL Server, Agent, full-text, Integration, Analysis, Reporting and Browser. Is there any service that should be left running all the time.
    Rendezvous
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 1:39 PM
  • Kaleem,

    None of the services need to be left running. I don't know if you need all the services for your work but depending on what's needed you even don't need to start the services.
    For knowing the right order you could open the services in you're Computer Management snap in to see if there are any depencies.
    I know that SQL-agent needs to be started after the SQL Server. Reporting Services depends on a database stored in a SQL Server database so depends also on SQL Server...
    Browser is only important if others need to connect from the network to your SQL servers so if not needed you don't even have to start it.

    Regards
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 3:12 PM

All replies

  • Hello Kaleem,

    Follow the steps mentioned in this link.

    http://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/

    Thanks,
    Prashanthi
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 5:19 AM
  • You can use Net Stop in a batch file to do this.  For instance:

    NET STOP "SQL Server (MSSQLSERVER)"
    NET STOP "SQL Server Agent (MSSQLSERVER)"

    Here's what you do:
        - Create a new text file.
        - Write out your NET STOP commands.
        - Rename the file from a .txt extension to a .bat extension
        - Run it any time you need to stop the services.

    You can do the same to start them back up again, but use NET START instead of NET STOP.

    Does this help?


    Aaron Alton | thehobt.blogspot.com
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 5:21 AM
  • Thanks Prashanthi and Aaron!!

    Both of above are nearly identical. However using the first one I was only able to stop a default instance whereas with second one using double quotes I was also able to both default and named instance(I have two instances running side by side). Also I would like to know what will be the right order to start the services among SQL Server, Agent, full-text, Integration, Analysis, Reporting and Browser. Is there any service that should be left running all the time.
    Rendezvous
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 1:39 PM
  • Kaleem,

    None of the services need to be left running. I don't know if you need all the services for your work but depending on what's needed you even don't need to start the services.
    For knowing the right order you could open the services in you're Computer Management snap in to see if there are any depencies.
    I know that SQL-agent needs to be started after the SQL Server. Reporting Services depends on a database stored in a SQL Server database so depends also on SQL Server...
    Browser is only important if others need to connect from the network to your SQL servers so if not needed you don't even have to start it.

    Regards
    • Marked as answer by Kaleem Khan Monday, March 23, 2009 3:57 PM
    Monday, March 23, 2009 3:12 PM