Wednesday, July 31, 2013

11 Keyboard Shortcuts Every SQL Server Geek Should Know

A smart programmer knows the ins and outs of the IDE in which he works. Keyboard shortcuts save a lot of time and can improve productivity as well. SQL server Management Studio has included over 100 keyboard shortcuts. Here, we will explore the most essential shortcuts which will make our daily programming life more easy and intuitive.
1. Open a new Query Window with current connection (Ctrl + N)
This shortcut opens up a new query window with an existing connection. It will query to the same database the current query window does.
SQL_Server_New_Window_Keyboard_Shortcut
2. Toggle between opened tabs (Ctrl + Tab)
This combination will help you switch between multiple opened tabs.
sql_server_toogle_tabs_keyboard_shortcut
3. Show/Hide Results pane (Ctrl + R)
If you have more lines of code in SQL Server after executing the query, the Results pane covers most of the window, so you need to scroll down continuously. Using this combination, you can save a lot of time.
SQL_server_keyboard_shortcuts_show_hide_results_pane
4. Execute highlighted query (Ctrl + E)
Hold this key combination, and execute the highlighted query to see the results.
SQL_server_shortcuts_Execute_highlighted_query
5. Cancel the executing query (Alt + Break or Alt + Scroll Lock)
Many times, we run the wrong query, and it may take time to show the results. Using this key pair, we can cancel the executing query quickly.
SQL_Server_Cancel_executing_query
6. Make selected text uppercase or lowercase (Ctrl + Shift + U, Ctrl + Shift + L)
Formatting code has always been a tough job for programmers. If you want to make a part of a query uppercase or lowercase, this key pair works well.
SQL_Server_Make selected text as Uppercase_lowercase
7. Display estimated execution plan (Ctrl + L)
Working on slow running queries always requires taking a look at the estimated execution plan.
SQL_server_display_estimated_execution_plan_keyboard_shortcut
8. Include actual execution plan (Ctrl + M)
The same goes with an actual execution plan.
sql_server_include_actual_execution_plan_shortcut
9. Intellisense list member and complete word (Ctrl + Space, Tab)
Microsoft’s Intellisense feature is a programmer’s delight. Suggestions like table names, columns and other information help programmers to write faster code. Using Ctrl + Space will give us suggestions, and using Tab, we can complete that suggestion.
sql_server_Intellisense_keyboard_shortcut
10. Go to line (Ctrl + G)
When trying to solve errors in a very long query, you need the error message which indicates the line number. Using this key combination, you can quickly jump onto that line.
Sql_server_keyboard_shortcuts_go_to_line
11. Comment and uncomment lines of code ( Ctrl + K & Ctrl + C; Ctrl + K & Ctrl + U)
Most of the time, programmers debug their code, and to do it faster, we keep commenting and uncommenting on a few lines of code. This key pair works perfectly for it.
sql_server_comment_uncomment_code
Go through our SQL Server archives to find out more useful tips for SQL Server geeks.