views:

530

answers:

5

Background: I'm using SQL Server Management Studio 2008 and I have a query window open that contains multiple queries.

Is there a keyboard shortcut that will allow me to execute a single query without highlighting the query I would like to run first? Some other SQL tools have shorcuts that run the query that is under the cursor, which keeps the hands on the keyboard, and away from the mouse.

Thanks everyone.

+1  A: 

I just mark the line I'm on (shift-down or shift-end), and then click ALT-X.

mbp
+2  A: 

I did some searching and was unable to find any keyboard shortcuts for executing individual lines in SSMS. There is a reference online though.

http://msdn.microsoft.com/en-us/library/ms174205.aspx

Personally I just highlight the row in question (shift-end or shift-down, etc.) and hit F5.

Mayo
Ah well, it will have to do. Thanks for take the time mmayo and everyone else!
Rydell
+1  A: 

Highlight the query you want to run, then F5.

Justin Niessner
+1  A: 

The usual Shift+Arrow or Shift+PgUp/PgDown that apply to most or all Windows apps...

Then I use CTRL-E to execute

gbn
To clarify this a bit, you can use shift+uparrow, shift+downarrow to highlight the query you want, then Ctrl+E to execute it. No mouse involved at all.
Crappy Coding Guy
A: 

I don't think Management Studio allows this, because then you would not be able to run multiple queries at once if the cursor was on any one of them, which could get annoying.

RedFilter
What some other editors do is to have two shorcut keys. One to Run everything in the window, and another to run the "current" query as defined by the cursor location.
Rydell