As a SQL Server developer you must know some keyboard shortcuts while working on SQL Server Management Studio, although it is not necessary to know shortcuts but it is something that you can use quickly and save a lot of time also can improve work productivity.
Lets see some keyboard shortcuts that you can use in SQL Server Management Studio.
To run, or execute selected T-SQL query, scripts you can press CTRL + E, or F5.
You can see, here we have a select query and to execute this query either you can press CTRL +E, or F5.
Lets run this query by pressing CTRL +E, or F5.
Show and Hide results pane
In SQL Server Management Studio, you can show and hide results pane.
In below screenshot, you can see query output in results pane.
In case, if you want to hide results pane than you can simply press keyboard CTRL +R.
When you press CTRL + R, you will see that results pane is hidden also you may notice that at the bottom it displays the three rows that means query result is just hidden not closed, or removed and to get back the results pane just press CTRL + R again.
Format selected text to upper case or lower case
Sometimes, you need to format a query either in lower case or upper case, that you can do using CTRL + SHIFT + U to format query in upper case and CTRL + SHIFT + L to format query in lower case.
Assume, that you want to format below query in upper case format.
Lets format above query into upper case, for this first select query and press CTRL + SHIFT + U.
You can see, query is formatted into upper case.
Lets format below query into lower case, for this just press CTRL + SHIFT + L.
Intellisense list member and complete word
Intellisense feature allows you to find the necessary information while writing the T-SQL script. It provides you suggestions such as table names, columns and other information that make you to write faster code.
Using Ctrl + Space will give us suggestions, and using Tab, you can complete that suggestion.
Lets see how to use Intellisense feature in SQL Server, for following T-SQL query lets select table name from a lists of objects that is suggested by Intellisense, just press CTRL + space just right after a “from clause”.
You can see when you press a CTRL + space, a lists of objects is bring up then you can select a table name that you want after that just press Tab.
Lets select table HumanResource, for this just start typing a few words of table name to refine a suggested list, once a table name appears in lists then select table name and press Tab, you will see a table name is selected in query editor.
Comment and Uncomment code
Sometimes, you need to comment and uncomment codes mostly when you writing or debugging a script, or may be you just comment the code for later use, reason could be anything.
So to comment and uncomment line code you can use CTRL + K & CTRL + C for commenting a code and CTRL + K & CTRL + U for uncommenting a code.
In below screenshot you can see, to comment the code just select the lines that you want to comment then press CTRL + K & CTRL +C.
You can see the line is commented as shown in right screenshot.
Now to uncomment the code just select the commented code lines then press CTRL + K & CTRL +U.
You can see the commented code line is now uncommented as shown in right screenshot.
Switch between opened tabs in Query Editor Window
You can switch between open tabs in Query editor window, for this you can press CTRL +TAB.
Lets switch between tabs, just press CTRL + TAB, and you will see it displays the lists of opened tabs, so that you can easily switch between them.
Close Current Tab
You can quickly close current tab by pressing CTRL + F4.
You can see when you press CTRL + F4, it asks you to save changes before closing the tab, as shown in below screenshot, so if you want to save changes before closing the tab then click on Yes else click on No.
Display Query Estimated Execution Plan
In case, if you want to see the estimated execution plan of slow running queries then you can press CTRL + L as shown below.
Intellisense – Refresh local cache
Sometime, when you create a new tables, view, or any other objects SQL Server Intellisense does not pick up the changes in database immediately. Because of that it shows a red mark underneath of newly created table name as shown in below left screenshot. So you need to refresh local cache manually by pressing CTRL +SHIFT + R.
You can see, once you refresh local cache by pressing CTRL +SHIFT + R, a red marked from table names is removed.
You can refer microsoft documentation on Keyboard shortcuts for SSMS – SSMS Keyboard shortcuts