Automatically start MS SQL Server

  • Can anyone suggest a way to bring-up the MS SQL Server if it is down apart from manually doing it. I would appreciate if someone can guide that through a script. I'm fighting and struggling to get a solution to it. Thanks in advance!

  • What do you mean? SQL Server will load on boot unless someone has tampered with the initial settings. Do you mean power was removed from the server and you want to "turn the server on"?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I mean that for whatever reason- If I need to start the SQL Server services including the agent, how do I do it through a script? I want to avoid a person sitting and just monitoring the server and bringing it up when it goes down because of any reason (may be power off/shutdown).

  • SQL Server runs as a service on Windows. You set the service to start automatically and every time Windows is restarted, SQL Server will be automatically started.

    Just set all SQL Server services that you want started when the server start to automatic. To do this, open Configuration Manager, select the services you want and modify the startup from Manual to Automatic.

    Jeff

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • u can create a batch to do so just write this in:

    net start MSSQLSERVER. if u have a default instance.

    if u have a named instance just replace the MSSQLSERVER with ur instance name.

    and for the agent write ur agent service name.

    u can get the service name from the control panel---> administrative tools---> services

    ..>>..

    MobashA

  • Hi Jeff, Jeffery, mobasha

    Thank you so much for your suggestions. This is the answer I wanted to confirm. Although I knew what you all have extended over to me but still would like if you could try to get over some script to bring SQL Server online or running. If any of you can try to manage it, it would be of a great help to me. Thanks again!

  • What do you want a script to do?

    Check to see if SQL Server is running, and if not - start it? If so, I wouldn't want to just restart SQL Server automatically, because - if it crashed it crashed for a reason and just automatically restarting the service could cause additional corruption.

    But, if you are really looking for something like that - then there are several options. Use a batch file that issues a NET START command and schedule it every few minutes, or install Powershell and look into Get-Service and Start-Service cmdlets, or use VBScript and use WMI to access the service and restart as needed, or other option.

    Jeff

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Hello everyone

    I just installed SQL Server 2005 Evaluation edition on my desktop and laptop. Everything has been working fine; I've configured all of my services to run automatically and everything. However, today when I attempted to run SSMS I get an error that says that the Sql Server Agent could not start on the local computer. I've made sure that the account that I configured everything on is the account that I'm logged into but I'm still getting errors. Could anyone possibly help me out?

    Also on my laptop I am attempting to connect to DAC with SQLCmd but it keeps telling me that the SQL Native Client has timed out; login expired. I unistalled all services and installed again and I am still getting the same errors.

    If anyone could help me I would greatly appreciate it.

  • for the service if its not a problem change the account to local administrator and make sure that u r writing the right password.

    and for the DAC please dont be offended but i have to ask, have u enabled the DAC connections from the Surface Configuration Aria?

    ..>>..

    MobashA

  • One thing that you should be made aware of... Unless you're installing the Developer's Edition of SQL Server, it must run on a Windows Server.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeffery: Do you have any script that uses the net start command utility that sufices such scenario? If so, do you mind forwarding it to me? Thanks!

  • Hi Ambuj

    You can use the below 2 scripts to check wether ur SQL server is running or not

    -- This Gives u the state of SQL server, Running or Stopped

    master.dbo.xp_servicecontrol 'QueryState', 'MSSQLServer'

    -- You can start or stop SQL server with the line below from DOS Prompt

    Net Start MSSQLServer

    Remember to Start SQL Server Agent once you have started

    Hope this helps

  • I had a situation over the long weekend where the SQL Server was restarted manually and even though all the SQL Server Services were set to start "Automatically" the SQL Server Agent did not come up. Fortunately most of my batch loads do not use the job scheduler but run by way of DOS batch scripts.

    When I went to restart the Service I noticed that in the properties for the Services for all the SQL Server services that in the recovery tab that the First Failure, Second Failure and Subsequent failures were all defaulted to "take no action".

    My question is what should they be set to "Restart the Service"? I searched MSDN and the web and didn't find anything on this subject. Is there any harm is setting them all to "Restart the Service"? (we have no OLTP databases only OLAPs in this server).

    This leads me to wonder why wouldn't they be defaulted to "Restart the Service".

    Thanks,

    DaveK

  • Jeff Moden (5/26/2008)


    One thing that you should be made aware of... Unless you're installing the Developer's Edition of SQL Server, it must run on a Windows Server.

    Express edition is can also be run on a PC. However, express is a limited version.

  • Why do we keep talking about scripts. There is no need for one. Go to

    Control-Panel -> Administrative tools -> Services...

    Find the "SQL Server *" services. the one's with (MSSQLSERVER) or (SQLEXPRESS) or whatever your instance name is, are the ones specific to your instance.

    Generally the Browser is disabled.

    You can also use the SSMS and right click on your server. Using SQL Server Configuration Manager you can configure the services to start automatically.

    Start -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Configuration Manager

    Something else worth looking at:

    Start -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Surface Area Configuration

    I hate to state the obvious some times, but RTFM.

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply