Toad for SQL Server: Program Your SSMS SP Keys


It happens more often than I like to admit, but I was asked a question about Toad that I could not figure out. A co-worker was trying to help a customer emulate a SSMS feature – the ability to program stored procedures to a keyboard shortcut or keystroke sequence.

I got part of the way there – Code Snippets. These can be customized and programmed by the end user to call frequently bits of code or scripts on demand. What I was missing was how to assign a keyboard shortcut to each snippet. Of course it was staring at me right in the face.

Thankfully @kekline put my nose in it in such a way I could not miss it – thanks Kevin! So just in case the rest of you are wondering how to do this, here’s a step-by-step:

How Microsoft SQL Server Management Studio (SSMS) Does It

  • Tools – Options
  • Keyboard page
  • Assign a shortcut to your favorite Stored Procedure (SP)
  • You can assign as many as 10 shortcuts (0-9)
  • Ctrl+1 in an editor window will auto-execute sp_who
  • How Toad Does It
    Toad ships with several dozen code snippets. You can invoke them by using a right-click in the editor, or you can assign a keyboard shortcut to each of them as you see fit.

    To see all the Code Snippets, open them on the menu View – Code Snippets. I am going to create a new snippet group called SSMS.

    Once the group is created, I will add a snippet for each of the three SPs that SSMS has coded. First, I will create a new snippet:

    The properties:

  • Design – this is where you put your code
  • Title – this is what will show in the snippet panel
  • Shortcut – this is the NAME of the snippet, and what you will use to invoke the command in the editor.
  • Help URL – you can document your code snippets. In this case I supplied the MSDN page for sp_help
  • I went ahead and coded all three SPs from SSMS:

    All Right, Let’s Do This Already!
    In the editor, to invoke the snippet, type the name and use the Ctrl+Spacebar key sequence. You then need to use F5 to execute it.

    So in the above example, here is what I type:
    ‘who’ followed by ‘Ctrl+Spacebar’

    Toad places the code into the editor. I can then edit or execute it as I require.

    That’s an extra keystroke over what SSMS requires. However, you do get to see the code used, and you have the ability to create an unlimited number of SPs you want to code into Toad. I think that is a fair tradeoff.

    Related Posts Plugin for WordPress, Blogger...

    Similar Posts by Content Area: ,