Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 Studio, hitting F5 runs the entire script. To run just the current statement, I have to manually highlight the statement I want, and then hit F5.

That is really annoying to me. Does anyone know of a tool with a keyboard shortcut to run just the current statement on a SQL Server? I would change tools just for this one feature.

Note: Oddly enough, even the free Toad for SQL Server does not let you run just the statement under the cursor.

like image 374
JosephStyons Avatar asked Aug 13 '09 14:08

JosephStyons


People also ask

How do I run a SQL script in management studio?

Click Query > Connection > Connect to connect to the server that contains the database you want to access. Select the appropriate StarTeam Server database. Open the tuning script, by choosing File > Open > foldername\scriptname. Execute the script, by clicking the Execute button on the toolbar or by pressing F5.


2 Answers

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!!

like image 77
dust Avatar answered Oct 06 '22 09:10

dust


You can check out this add-in for SSMS 2012. Place the cursor within the statement you want to execute and press CTRL+SHIFT+E

SSMS Executor - https://github.com/devvcat/ssms-executor/releases

Update:
Project moved to github and the addin re-written to support SSMS 2014, SSMS 2016. (Previously, the project lived on codeplex, at SSMS Executor - http://ssmsexecutor.codeplex.com/.)

like image 38
Stanislav Stoyanov Avatar answered Oct 06 '22 09:10

Stanislav Stoyanov