views:

297

answers:

2

I believe like many developers I have both Visual Studio and SQL Server installed on my PC. Since I use the PC for various tasks not just for development, SQL Server is by default stopped until I need it for another session of development.

Currently I go directly to Administrative Tools->Services to start/stop SQL Server. Not that it bothers me, but it would have been much better if I could have something like this standard start/stop button directly in Visual Studio toolbar. Is it possible somehow?

Another idea would be to start the service at the start of Visual Studio and automatically stop it when I close the application. Is this behavior easier to achieve?

I have VS 2008 and SQL 2008.

+1  A: 

You should just simply go to the Services Manager, however to get there from VS 2008:

  1. Go to Server Explorer Tab
  2. Expand out the Servers section
  3. Expand out the name of your computer
  4. Right click on the Services section and select Launch Services Manager
  5. From Services Manager, select SQL Server and do whatever Start, Stop, Restart action you wish to achieve

Another way would be the commaind line approach of:

net stop "SQL Server (MSSQLSERVER)" net start "SQL Server (MSSQLSERVER)"

Nissan Fan
add the command line for starting and stopping to your Tools menu / External tools and you're done!
marc_s
+2  A: 
  1. In Visual Studio, go to Tools -> External Tools...

  2. Click the add button, and enter Start SQL Server for the title and for the command put:

    C:\WINDOWS\system32\net.exe

  3. For the arguments, put:

    start mssqlserver

  4. Untick "Close on exit" and tick "Use output window".

  5. Repeat steps 2-4 to create the stop command, but for the arguments put:

    stop mssqlserver

You know have two external tools configured which you can run by selecting them from the Tools menu in Visual Studio.

You can also add a shortcut button in any toolbar by right-cliking on the toolbar area, selecting customise, and then dragging the relevant external tool link (unfortunately VS refers to them as this, so you will have to figure out which one to choose) to a toolbar.

adrianbanks
You could change the command to: C:\Windows\System32\net.exeand the argument to: stop mssqlserverCheck the "Use Output Window" option if you don't want the DOS window.
Todd Ropog
I'd already said to tick "use output window" in step 4. Using net.exe instead of cmd.exe /k... is nicer though -> updated answer.
adrianbanks
Sorry, glossed over the output window item.
Todd Ropog