Edit: I’ve published an updated version of my cheat sheet. Find the latest version by in the sidebar –>
I’ve presented my Shortcuts from an Impatient DBA talk a few times now, and I really love it. Everyone learns something, whether you’re a Junior Developer, or a multi-decade veteran, or a Data Platform MVP.
This past weekend, after presenting at SQLSaturday Chicago, Brent Ozar (blog|twitter) suggested that as an attendee, it would have been nice to have some sort of handout to follow along with. I guess Brent was learning so many things that he couldn’t take notes fast enough.
On my flight home, I spent some time putting some of the things from my presentation into a one-page cheat sheet. I’ll have these printed up and have them on-hand for next time…but if you want it now, you can download the PDF and print one for yourself.
I took this as a challenge, as I thought I knew every keyboard shortcut, but STILL learned something! I have one that I use all the time in SSMS but it might should go under the Windows Shortcut category: it’s Shift+F10. This equals a right click, I find after a bit of practice, it’s quicker than moving the hands to the mouse and back again. I use it in the Object Explorer for everything but mainly to open items like Job Activity Viewer, Replication Monitor, Activity Monitor.
Glad you learned something!
The shift-F10 thing is cool. I’m definitely making a note of that myself.
Doh! I just used my favorite key combo and forgot to mention it in the first post.
It enables “advanced highlighting” (my term). It allows you to do ALL kinds of cool stuff. Let’s say you needed(?) to kill a runaway process on a test box and it generated 50 spids. Run sp_who3, paste the list of spids and Alt+Shift+DownArrow to get in front of the spid list, type “kill ” and you’re done. It’s handy for all sorts of text manipulation.
Couldn’t do my job without it.
I love that command! That’s one that always generates excitement during my SQLSaturday sessions.
Thank you for putting together something so nice to share, and for leaving some “Ctrl + #” spaces since I’m sure we all have a few favorites mapped to some of those! (Personally, I’m dependent on sp_helptext mapped to Ctrl + F1; and I’m sure most DBAs have an sp_whom/sp_who2 in there.)
For me, Ctrl+F1 is permanently sp_blitzindex (from Brent Ozar) and Ctrl+3 is sp_WhoIsActive. So We’re totally on the same page!
Especially for anyone just starting out with query shortcuts, having a spot to jot down your mappings is really important.
Here’s one that’s not on your list, but I can’t live without now…
One of my pet peeves is writing a query in an editor tab in SSMS, adding/altering a table/view/function, and then watching all the red squiggles appear under the field names in my query when I reference the updated table/view/function. It happens because the editor window doesn’t know about the other changes that I just made.
To resolve it, press CTRL + Shift + R to refresh the database schema in the current editor and watch all of the red squiggles dissappear!
I like Alt-X instead of F5 to execute a query. 😉
You and me both — the ALT-X to execute a query is so much easier to use than the ALT-F5 (2 fingers v. 2 hands). In addition, back in “the day”, there was a keyboard shortcut that would allow you to toggle back and forth between the query and the results. It was a something-B, I think. Does anyone know if there’s a comparable in SQL 2014?
You can also use Shift+F5 to have SSMS parse your query to check for errors. It doesn’t catch everything, but is very useful.
Err… it’s actually Ctrl+F5
For me it’s just F5 (not Alt+F5), so F5 wins over ALT+X. Back in the day 2005 maybe, I remember a really cool shortcut related to “B”. When you would use the mouse, it was REALLY hard to get it to stop on the line between the query and the results to adjust the window size, but Ctrl+B would “snap” the mouse to that line and allow you to easily adjust the window size. In the newer versions, they just made it easier to stop the mouse on that line and removed Ctrl+B.
Also, I see at the top that it talks about Ctrl+Tab, but if you hold Ctrl down and just tap the Tab button (but leave Ctrl down), you get the list of all windows you can navigate to (ala Visual Studio), you can use the arrow keys to move to any window – best way to get from Object Explorer to Query windows and back.
I love this keyboard stuff. I thought I was the only one!
The Alt+Shift+(Arrow Keys) doesn’t work in SQL 2008 or R2
Unfortunately, it does not.
Fortunately, you can install the newer management tools on your desktop, and they are backwards compatible to older DB Engines.
Sounds like a good enough reason to upgrade! At least SSMS.
Complete list in markdown format you can find here: https://github.com/ktaranov/sqlserver-kit/blob/master/SSMS/SSMS_Shortcuts.md
And official MSDN recourse here: https://msdn.microsoft.com/en-us/library/ms174205.aspx
Ctrl-I lets you do a quick search (while Ctrl-F or Ctrl-H opens the usual Find/Replace dialog). Just press Ctrl-i and start to typing and it will jump to the first occurence (e.g. Ctrl-I+f+r+o+m finds the FROM statement).
If you have opened a table with the “select / edit top x rows” from the object explorers context menu, you have to use Ctrl-R instead of F5 to (re-)run the query (you can use the SQL icon in the toolbar to see the query text in this context).
My colleague found another handy shortcut. You can highlight a field from the grid view output and drag it into the query window or anywhere else you want. e.g you’re querying management views for queries to tune you click on the text output and drag it into another query window to view the query plan. I know it only saves a crtl c and a ctrl v but it makes things just a bit easier.
I never knew that. That’s a cool trick!