SQL Management Studio - 执行当前行
在 SQL Server 2008 Management studio 中,我可以按 F5 来执行当前查询窗口中的所有内容。我还可以突出显示一个查询,然后按 F5 运行该突出显示的查询。
有没有办法可以运行光标所在的单个查询,或者运行光标所在的查询,直到第一个“;”,而不是必须突出显示查询?
In SQL Server 2008 Management studio, I can hit F5 to execute everything in the current query window. I can also highlight a query, and hit F5 to run that highlighted query.
Instead of having to highlight a query, is there a way I can run the single query my cursor is on, or run a query my cursor is on up to a the first ';'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
在选项中,您可以配置要显示的行号,然后只需单击行号即可突出显示整行。
In options you can configure line numbers to be displayed, then you can just click on a line number, which will highlight the whole line.
不幸的是,MSDN SMSS 键盘快捷键列表中没有这样的键盘快捷键,而且我没有看到任何录制宏的方法来做到这一点。我发现的唯一解决方案需要创建一个加载项,这相当需要做一些工作才能节省一点钱。
Unfortunately no there is no such keyboard shortcut in the MSDN list of keyboard shortcuts for SMSS, and I don't see any way of recording a macro to do so. The only solutions I've found require creating an add-in which is quite a bit of work for a little savings.
安装 SQL Complete Express。它是一个免费的 SSMS 插件(也是付费版本),它允许使用 CTRL+SHIFT+E 执行当前语句,我已将其重新映射到 F9,因为我也经常使用 Toad。
我尝试了其他几个,但它们要么无法与 SSMS 2012 配合使用,要么就是我无法使用它们。
我发现智能感知比内置版本更快。
Install SQL Complete Express. Its an SSMS plugin that free (also a paid version) and it allows using CTRL+SHIFT+E to execute current statement, I have remapped it to F9 as I use Toad frequently too.
I tried several others but they either didn't work with SSMS 2012 or I just didn't get on with them.
I find the intellisense quicker than the built in version to.
如果您能够使用 SSMS 2012,那么您可以使用 SSMS Executor 添加,如所述st-stoqnov 在 他对类似问题的回答。
Alpha 版本 还适用于 SSMS 2014/2016/2017。
If you are able to use SSMS 2012 then you can use the SSMS Executor add in as mentioned by st-stoqnov in his answer to a similar question.
An Alpha release is also available for SSMS 2014/2016/2017.
在 SQL 中,结束一条语句后,只要您的光标位于该行的末尾,您所要做的就是按
SHIFT+HOME
,它将突出显示整个语句,然后您可以继续按f5....In SQL after concluding a statement and as along as your cursor is at the end of the line all you have to do it hit
SHIFT+HOME
and it will highlight the entire statement and you can then proceed to press f5....对于键盘用户:
我发现将光标向下移动到查询行的末尾,或者如果该行为空,则向下移动到下面的行,然后使用“SHIFT + 向上箭头”选择完整的查询。选择后按 f5
For keyboard users:
I found going down with the cursor to the end of the query line, or the line bellow if it is empty, and then using "SHIFT + arrow up" to select the full query. After selection hit f5
新的SQL Prompt有这个功能。您按
SHIFT+F5
,光标当前所在的语句将被执行。这可以节省大量时间,并且是从一开始就应该存在的功能。The new SQL Prompt has this feature. You press
SHIFT+F5
and the statement that your cursor is currently on will be executed. That's a big time saver and a feature that should have been there from the start in the first place.我刚刚免费安装了Devart's Sql Complete Express。使用 ctrl-shift-e 即可完成您想要的操作。
现在我只需要交换,使 ctrl-e 执行当前和 ctrl-shift-e 一切......
I just installed Devart's Sql complete express that is free of charge. With ctrl-shift-e it does what you want.
Now I just need to swap, to make ctrl-e execute current and ctrl-shift-e everything...