How can I run just the statement my cursor is on in SQL Server Management Studio?

后端 未结 24 574
夕颜
夕颜 2020-12-04 17:19

As a long time Toad for Oracle user, I have gotten used to hitting Ctrl+Enter and having just the statement under the cursor be executed.

In SQL Server Management St

相关标签:
24条回答
  • 2020-12-04 17:50

    I use a workaround: I comment queries I'm not using. You can use CTRL-K, CTRL-C to comment the SQL you've highlighted. Use CTRL-K, CTRL-U to uncomment. That way, you can comment all other queries, and execute the one you're interested in with F5.

    0 讨论(0)
  • 2020-12-04 17:51

    Easiest way to do this is assignment for CTRL + Enter combination for action Query.Execute in SQL Server Management Studio.

    1. Open Tools > Options menu.
    2. Select Environment > Keyboard page in left pane.
    3. Find Query.Execute action and select it.
    4. Set SQL Query Editor in "Use new shortcut in:" dropdown list.
    5. Now type CTRL + Enter combination in press shortcut keys: textbox.
    6. Click the Assign button.
    7. Change Shortcut currently used by: to Query.Execute (Ctrl+Enter (SQL Query Editor))
    8. Click OK. Done.
    0 讨论(0)
  • 2020-12-04 17:52

    Ok, so what I'm getting from all these answers is "No, that is not possible."

    Edit:

    Here is how I was able to do this:

    1 - Download SQL Developer

    2 - Download the jTDS driver

    3 - Follow these instructions to add that driver to SQL Developer

    4 - Connect to SQL Server using SQL Developer (cool!)

    5 - Run it and life is good

    0 讨论(0)
  • 2020-12-04 17:55

    Use Ctrl+KU to select a line. Then use F5 to run it.

    Although it only works for single line selection, still I find it quite useful.

    Hope it helps!!

    0 讨论(0)
  • 2020-12-04 17:56

    Somebody suggested this features on Devart dbForge SQL Complete (addon for Management Studio) , and it's still in the development stage. Let's hope that it's finished and doesn't get abandoned halfway through development.

    0 讨论(0)
  • 2020-12-04 17:56

    If it's the having to move your hand to the mouse part that bothers you, you can hold the Ctrl down while hitting an up or down arrow key to select a line at once.

    0 讨论(0)
提交回复
热议问题