Skip navigation

Query Editor Shortcuts

Query Editor is one of Microsoft's core SQL Server 2005 management tools. It's an entirely new tool, not just an upgrade of the Query Analyzer tool in earlier SQL Server versions. It uses many familiar Query Analyzer keyboard shortcuts, but you'll find new ones as well. I've gathered 10 of my favorites here.

10. Run the Statement: F5


I use the F5 shortcut key the most. You can use F5 to run selected text or all of the statements in the Query Editor window—much handier than clicking Execute.

9. Cancel the Currently Executing Query: ALT+BREAK

If a query is taking an unexpectedly long time to execute, you can hit ALT+BREAK to cancel the query execution, returning control to the Query Editor editing window.

8. Copy, Cut, Paste, Undo, Redo: CTRL+C, CTRL+X, CTRL+V, CTRL+Z, CTRL+Y

Query Editor conveniently uses standard Microsoft editing keyboard shortcuts.

7.

Jump to the Next Word: CRTL+ARROW

Another handy keyboard shortcut, CTRL+ARROW lets you rapidly move through the contents of the QE editing window one word at a time. Skip to the right with CTRL+RIGHT ARROW; skip to the left with CTRL+LEFT ARROW.

6. Comment the Selected Line: CTRL+C

While I'm developing code or testing statements in Query Editor, I use CTRL+C to comment the line in the Query Editor editing window. You can uncomment the line by using CTRL+U.

5. Convert to Uppercase: CRTL+SHIFT+U

Before I save the final copies of stored procedures or T-SQL batches, I ensure they follow the coding convention of using all caps for T-SQL keywords by selecting the text and pressing CRTL+SHIFT+U. To convert to lower case, press CTRL+SHIFT+L.

4. Display the Go To Line Dialog Box: CTRL+G

When you're working with large stored procedures, CTRL+G displays the Go To line dialog box, which lets you enter a line number and click OK to jump directly to the specified line.

3. Output Results to Text: CTRL+T

If you want query results in text format hit CTRL+T. Conversely, CTRL+D toggles the output back to grid format.

2. Display the Execution Plan: CTRL+L

While you're developing a query, press CTRL+L to execute either the selected text or all of the statements in the Query Editor window and display the execution plan.

1. Adding Your Own Shortcuts

Query Editor lets you define 12 of your own keyboard shortcuts. At the Tools, Customize menu option, click Keyboard then select Keyboard under the Environment node. By default, ATL+F1 is set up to run sp_help, CTRL+1 runs sp_who, and CTRL+2 runs sp_lock. To add your own shortcut, enter the name of a stored procedure next to one of the available shortcuts.

TAGS: SQL
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish