Command/script to enable and disable SQL Server

command-line-interfaceservice

I have SQL Server disabled on my machine and have to manually go into services (services.msc) to enable it and the agent. I'd like to write a batch script that I can run to enable them for me. Is it possible? When I do net start in the command prompt I don't see it listed so I'm not sure if it's possible.

EDIT:
I'm using Windows Vista. I keep it disabled because having it run all the time slows my comp down and not all my web dev requires it. I'm more productive with it off most of the time because it is so resource intensive, especially for boot time.

Best Answer

If you set the service to manual, you can create a batch file or two to start and stop it without going into the services menu. The commands would be:

net start SQLAgent$instancename

net stop SQLAgent$instancename

Example would be net start SQLAgent$MICROSOFTSMLBIZ for a BCM instance.

Similar to the agent, the server itself would be:

net start MSSQL$instancename net stop MSSQL$instancename