SQL Server Management Studio keyboard shortcuts (Part 1 of 2)

By:   |   Comments (21)   |   Related: 1 | 2 | 3 | 4 | > SQL Server Management Studio Shortcuts


As responsibilities are growing every day, a DBA or developer needs to improve his/her productivity. One way to do this is to use as many shortcuts as possible instead of using your mouse and the menus. In this tip we take a look at common tasks you may perform when using SSMS and the associated shortcut keys.


We often overlook the shortcut keys which SSMS (SQL Server Management Studio) provides for increasing our productivity as a DBA or developer. In this tip series I will talk about some of these shortcut keys to help you use SSMS for more proficiently.

Launching SSMS

When launching SSMS you probably go through START-> All Programs -> SQL Server 20XX and click on SQL Server Management Studio, but this is not the only way.

Another options is to click on START -> Run or press Windows + R, type ssms and click OK (or hit ENTER) which will launch SSMS.

You can also specify different parameters or switches

  • The -E switch will let you connect to the local instance using Windows authentication.
  • The -U switch is used to specify a user and -P to specify the password
  • If you want SSMS to connect to a specific database you can use the -d switch
  • If you want a script file to be opened in SSMS you can specify the location and name of the file. This will just open the file in SSMS and will not execute the code. If you need to execute a script file you can use the SQLCMD utility.
  • To close SSMS you can use ALT+F4.
use run to launc ssms

As I said before, you can simply open the SSMS or you can specify the -E switch to open SSMS and connect using Windows authentication. If the current user does not have sufficient permissions obviously it will fail.

specify the e- switch to open ssms

When we open SSMS a splash screen appears while loading SSMS in the memory. You can specify -nosplash switch which opens SSMS without the splash screen.

open ssms without the splash screen

If you are scratching your head trying to remember all these switches, you don't need to because you can use -? which gives you the different command options as shown below. You can find more information about this here.

use -? which will give you all the command options
list of ssms switchs

Changing Databases

Once you are in a Query Window in SSMS you can use CTRL+U to change the database. When you press this combination, the database combo-box will be selected as shown below. You can then use the UP and DOWN arrow keys to change between databases (or type a character to jump to databases starting with that character) select your database and hit ENTER to return back to the Query Window.

in a query window in ssms you can change the database

Changing Code Case (Upper or Lower)

When you are writing code you may not bother with using upper or lower case to make your code easier to read. To fix this later, you can select the specific text and hit CTRL+SHIFT+U to make it upper case or use CTRL+SHIFT+L to make it lower case as shown below.

you can change code case after you are done writing it
changing code case in ssms

Commenting Out Code

When writing code sometimes you need to comment out lines of code. You can select specific lines and hit CTRL+K followed by CTRL+C to comment it out and CTRL+K followed by CTRL+U to uncomment it out as shown below.

you can comment out lines code
using commenting out code shortcuts in ssms

Indenting Code

As a coding best practice you should to indent your code for better readability. To increase the indent, select the lines of code (to be indented) and hit TAB as many times as you want to increase the indent likewise to decrease the indent again select those lines of code and hit SHIFT+TAB.

indenting code

Bookmarking Code

When you have hundreds of lines of code, it becomes difficult to navigate. In this case you can bookmark lines to which you would like to return to. Hit CTRL+K followed by CTRL+K again to toggle the bookmark on the line. When you bookmark a line a tiny light blue colored square appears on the left side of the query window to indicate that the line has been bookmarked as you can see in the image below.

You can press CTRL+K followed by CTRL+N to move to the next bookmarked line from the current cursor location likewise to move back to the last bookmarked line you can hit CTRL+K followed CTRL+P from the current cursor location.

To clear all bookmarks from the current window you can hit CTRL+K followed by CTRL+L.

bookmark lines of code you would like to reurn to later

There might be several bookmarks you have placed in your query window and to manage these easily SSMS provides a Bookmarks window. To launch this window simply hit CTRL+K followed by CTRL+W and you can manage almost every aspect of bookmarking from this window as shown below including renaming the bookmarks.

organize bookmarks in the ssms bookmark window

Search and Find / Replace Text

Sometimes you need to find specific keywords or replace some specific keyword with another keyword. To launch the Quick Find dialog box press CTRL+F or CTRL+H for the Quick Replace dialog box. You can even fine tune your search with other options available in the dialog box or you can bookmark all the lines which contain your search string. To close the dialog box press ESC. You can also press F3 to find the next keyword match.

using the quick find dialog box

Goto Line Number

If you know the line number you want to go to you can use CTRL+G to open the Go To Line dialog box and type the line number and press OK (or hit ENTER) to go to that particular line number.

go to line dialog box

Opening Query Windows and Switching Tabs

Next to open a new query window you can hit CTRL+N or to open a existing script file hit CTRL+O. You can hit CTRL+TAB to switch between open query windows.

More Query Window Shortcuts

Please note apart from the above mentioned shortcut keys these are some standard shortcut keys which work in SSMS as well.

  • CTRL+A to select all the text in the current query window
  • CTRL+C to copy selected text
  • CTRL+V to paste text
  • CTRL+X to cut selected text
  • DEL to delete text
  • CTRL+P to launch Print dialog box
  • CTRL+HOME to go to the beginning of the query window
  • CTRL+END to go to the end of the query window
  • CTRL+SHIFT+HOME to select all text from the current location to the beginning of the query window
  • CTRL+SHIFT+END to select all the text from the current location to the end of the query window
  • ALT+F4 to close SSMS
Next Steps

sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip

About the author
MSSQLTips author Arshad Ali Arshad Ali is a SQL and BI Developer focusing on Data Warehousing projects for Microsoft.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips

Comments For This Article

Thursday, April 21, 2016 - 1:14:05 AM - Chen Back To Top (41291)

Hi, how to execute the select query? What is the short cut key for doing this?



Thursday, October 22, 2015 - 6:16:50 PM - Kenny Wymore Back To Top (38959)

Another trick is bulk inserting values across multiple rows. Say you had copy and pasted a list of columns from an external list or from sys.columns or wherever and you want to use them to select from a table. Your query window might look like this:







from test

Instead of adding a comma after every column name or before every column name manually, you can place your cursor in front of the last column [e], hold down Alt + Shift and then at the same time, move your cursor up the list to [a] with your up arrow key. Then release Alt + Shift and hit the comma key and it will insert a comma before all of the column names. Output should look like below:







from test

Alternatively, you could use it at the beginning of a list and then move the cursor down to the end. Works really well when aliasing a large number of columns pulling from the same table as well. 

Sunday, August 9, 2015 - 6:29:26 AM - sandani Back To Top (38410)


While trying the above shortcut doesn't work on ssms 2012.what to do

Friday, November 7, 2014 - 5:41:40 PM - Minh Back To Top (35228)

You may want to note somewhre that the Find/Replace pop Dialog may get confused and no longer popup on screen - at all!

It is becuase it is opening up off screen.

There is a "Window" -> "Reset Window Layout" menu option in the editor.  That should fix it

Friday, November 7, 2014 - 5:40:59 PM - Minh Back To Top (35227)

You may want to note somewhre that the Find/Replace pop Dialog may get confused and no longer popup on screen - at all!

It is becuase the dialog is somehow opening up off screen.

There is a "Window" -> "Reset Window Layout" menu option in the editor.  That should fix it

Monday, July 28, 2014 - 4:24:20 PM - vishu Back To Top (33909)

Hello, I'm wondering if someone can tell me why my "quick replace" function (under the Edit menu) in SSMS won't work--it was working fine up until Friday, and then it stopped working--is there an option to turn it back on, or is there a service or something which is missing? Thanks!

Thursday, July 17, 2014 - 1:57:29 AM - Ashish Kalra Back To Top (32746)
Useful Information

Wednesday, October 23, 2013 - 3:28:45 AM - DarurAshok Back To Top (27239)

F6 key is used to switch between Query, Results and Messages Pane.


Have an amazing day ahead.

Saturday, September 1, 2012 - 12:50:01 AM - Mayank Back To Top (19362)

Thanks so much for this wonderful Knowledge shared with us.
It has helped me a lot, No one is here to explain these things in Job (as a Fresher) but You helped Me.
Also thanks to Martin for posting the Main Shortcut which was required by Me because of which I had navigated on this Webpage.

Thank You :)

Tuesday, July 24, 2012 - 8:19:38 AM - Andrei Back To Top (18771)

I have recently published SSMSBoost add-in for SSMS (currently free). It allows to define/redefine any keyboard shortcut in SSMS and also has "Dump" feature, that will make a listing of all available commands in SSMS and all currently assigned shortcuts.

Wednesday, June 22, 2011 - 12:02:58 PM - Dipak Back To Top (14063)

Thanks Arshad.  I have SQL 2008 Management Studio. The version is 10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Perhaps I need a newer version in order to generate a new query window with CTRL-N.

Friday, June 17, 2011 - 3:24:14 AM - Arshad Back To Top (14036)

Thanks Aurin for encouraging words.

Yes that is very much possible, try hitting F6 for switching between the Query, Results and Messages panes.


Friday, June 17, 2011 - 3:17:32 AM - Arshad Back To Top (14035)

Hi Deepak,

I just tried CTRL+N on SQL Server 2008 and SQL Server 2008 R2 and it works fine.

Thursday, June 16, 2011 - 9:22:42 AM - Aurin Back To Top (14031)

My very tired hand thanks you.  Isn't there a shortcut for switching between the Query, Results and Messages panes?

Thursday, June 16, 2011 - 6:17:32 AM - Dipak Back To Top (14030)

Hello, this is a good post with very useful shortcuts. I love using shortcuts and some of these I never knew about.

A couple of comments:

1. In the Changing Databases section, one small addition is that F4 could be used to display the dropdown list of databases

2. In SQL 2005 I always use CTRL-N for a new query window, however this doesnt work for me in SQL 2008. Is the functionality really there, or is it something with my config?

Wednesday, June 1, 2011 - 2:41:50 PM - Arshad Back To Top (13953)

Hi Michael,

The name of SSMS executable changed in SQL Server 2008 and later versions and its ssms.exe now, for SQL Server 2005 try SqlWb.exe

Hope it helps.




Wednesday, June 1, 2011 - 10:43:50 AM - Michael Back To Top (13951)

In your article, you stated,

"When launching SSMS you probably go through START-> All Programs -> SQL Server 20XX and click on SQL Server Management Studio, but this is not the only way. Another options is to click on START -> Run or press Windows + R, type ssms and click OK (or hit ENTER) which will launch SSMS."

I work in a multi-OS, and multi-SQL enviroment and the only instance I found where the START option works is with the 2008 R2 servers running SQL 2008 R2. I have, in my environment, Server 2003 running SQL 2005, and the Start >> Run doesn't work in these environments. In these environments I receive the following error;

Windows cannot find 'ssms'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, then click Search.

I also have SQL 2000 still running on the Server 2000 platform (for only a short time longer... fingers crossed), and it doesn't work there either.

So, what is the catch? Does this work with any SQL 20xx as long as it resides on MS Server 2008 R2? Or does this work with only SQL 2008 R2, on any platform? You kind of failed to mention that in your article... Can I make an environmental variable to point to the 'ssms' on the platforms that aren't Server 2008, or doesn't have SQL 2008 R2. I use to know how to do that, but it has been a long time since I have done it.

Wednesday, June 1, 2011 - 9:37:58 AM - Martin Back To Top (13949)

Thanks a lot for your feedback Arshad!.

Although I do see Emilia's post closed with "it won't be fixed" resolution. Perhaps in a future release we would count with our really good friend Ctrl + B :)



Wednesday, June 1, 2011 - 9:03:18 AM - Arshad Back To Top (13948)

Sorry I missed the link, here it goes:


Wednesday, June 1, 2011 - 9:01:42 AM - Arshad Back To Top (13947)

Hi Martin,

This has already been brought up before product team on this connect item, as per their reply they are working on it.




Wednesday, June 1, 2011 - 8:20:50 AM - Martin Back To Top (13945)

Hey, nice post!.

Since you talked about shortcut, I'd like to ask if you are aware of what happened with one shortcut (for me, the best) which used to be used in SQL-2000 version.

As you know, Ctrl - R will show/hide the Results Panel. In SQL-2000 there was a Ctrl-B which would set automatically the mouse cursor between the Results Panel and Query Panel so that you can manage the size of Results Panel without tryinig to match the border panel with the mouse. This was really great and it helped me a lot when I used to work using Remote Desktop.

Then, when SQL-2005 arised, I couldn't find anymore that shortcut. Would you know if this shortcut is still out there?

get free sql tips
agree to terms