如何直接从Visual Studio启动/停止本地SQL Server服务? [英] How to start/stop local SQL Server service directly from Visual Studio?

查看:126
本文介绍了如何直接从Visual Studio启动/停止本地SQL Server服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信和许多开发人员一样,我的PC上同时安装了Visual Studio和SQL Server.由于我将PC不仅用于开发,还用于各种任务,因此默认情况下,SQL Server会停止运行,直到我需要它进行另一次开发为止.

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.

当前,我直接转到管理工具"->服务"以启动/停止SQL Server.但这并没有打扰我,但是如果我可以在Visual Studio工具栏中直接使用这种标准的开始/停止"按钮,那就更好了.有可能吗?

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?

另一个想法是在Visual Studio启动时启动服务,并在我关闭应用程序时自动将其停止.这种行为更容易实现吗?

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?

我有VS 2008和SQL 2008.

I have VS 2008 and SQL 2008.

推荐答案

  1. 在Visual Studio中,转到工具"->外部工具...".

  1. In Visual Studio, go to Tools -> External Tools...

单击添加按钮,然后为标题和放置的命令输入启动SQL Server :

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

C:\ WINDOWS \ system32 \ net.exe

C:\WINDOWS\system32\net.exe

  • 对于参数,输入:

  • For the arguments, put:

    启动mssqlserver

    start mssqlserver

  • 取消选中退出时关闭",然后选中使用输出窗口".

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

    重复步骤2-4以创建stop命令,但对于放置的参数:

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

    停止mssqlserver

    stop mssqlserver

  • 您知道已经配置了两个外部工具,可以通过从Visual Studio的工具"菜单中选择它们来运行它们.

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

    您还可以通过在工具栏区域上右击,选择定制,然后拖动相关的外部工具链接来在任何工具栏中添加快捷按钮(不幸的是VS指的是它们,因此您必须弄清楚哪个一个可供选择)到工具栏.

    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.

    这篇关于如何直接从Visual Studio启动/停止本地SQL Server服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆