Custom Keyboard Shortcuts in SSMS

Content rating: Beginner, Tip 

I KNOW I blogged about custom SSMS shortcuts before, but dang if I can find it.

I use certain commands SEVERAL times a day, and I’m in love with shortcuts. So the SMS keyboard shortcuts dialog is just perfect for me.  You already have three default shortcuts when you install SSMS:

  • Alt+F1 – sp_help
  • Ctrl+1 – sp_who
  • Ctrl+2 – sp_lock

So if you want info on your Region table, you’d type Region, highlight it, and hit Alt-F1. Go on, try it. Isn’t that awesome?

Well I also use sp_depends and sp_helptext a lot, so I have those set to Ctrl+3 and Ctrl+F1, respectively. To add a keyboard shortcut:

  1. Select Tools > Options > Environment > Keyboard
  2. Click an empty space next to the shortcut you want.
  3. Type or paste your command.
  4. Click OK. (Note that shortcut changes take effect in query windows you open after the change.)

Today I added a new one that I use a lot – I use this query to search for a word or phrase within all SQL programmable objects:

SELECT OBJECT_NAME(OBJECT_ID) nm
FROM sys.sql_modules
WHERE definition LIKE '%region=0%'

This gives me the names of all SPs, views, triggers, and functions with the EXACT phrase “region=0” in it.  It’s not foolproof, but it’s extremely useful. So finally today I added this to my shortcuts as Ctrl+0:

SELECT OBJECT_NAME(OBJECT_ID) nm
FROM sys.sql_modules
WHERE definition LIKE '%

Why didn’t I think of this before? Now all I have to do is type “region=0%'”, highlight it and push Ctrl-0.  I LOVE shortcuts.

Snippets

Many thanks to MladenPrajdic and SQLChicken for mentioning Snippets to me. With Redgate’s SQL Prompt (which I ADORE) or the SSMS Tools Pack kit (free, and which I also ADORE), you can set it up to autocomplete commands for you. To quote SQLChicken: “Snippets are a godsend. You can create one where you type wtf and press TAB and whatever command u want comes up.” Nice, very nice. Now if Only I could install SQLPrompt or the toolkit at work… 🙁

Happy days,

Jen McCown

http://www.MidnightDBA.com

3 thoughts on “Custom Keyboard Shortcuts in SSMS

  1. Vikrant More

    Thanks! for posting its really a valuable post.
    how can we run the User defined procedure with parameter with shortcut in SSMS.

  2. Brian

    I know this is an old post, but just FYI, SSMS Tool Pack (which is awesome!) is no longer free for SSMS 2012+ – it costs 30 Euros to license it.

  3. Pingback: Management Studio Shortcut - Change Connection > The MidnightDBA Star-Times

Comments are closed.