Is there a way in Microsoft SQL Server Management Studio, to program a function key? I'd like to map a function key to "SELECT * FROM dbo."
Yes, there is Tools-->Options-->Enviroment-->Keyboard
there are already a bunch there , you can type anything you want in the Stored Procedure column. However that will just execute, I guess you can do a PRINT 'SELECT * FROM fbo.' in your case
It's outside of the studio but I use AutoHotKey (google it). You can write little keyword macros. Even launch applications with a few keystrokes. All in an effort to reduce time on the mouse.
In SSMS:
- Tools
- Options
- Keyboard
- Select the desire shortcut (only 12 options, 3 of which are hard-coded and cannot be changed, which is better than none, but not by much)
- Enter what you'd want run (for example, I have CTRL+0 set to "USE tempdb"
- Save
These hotkeys will not be available to currently opened query windows, only windows opened after you've created them.
Note that if you make it a procedure call, such as as CTRL+1's "sp_who", hilight a block of text, and hit the hot key, the highlit text is passed in as a parameter to the procedure. Try it with CTRL+1 and see. (...and you get lots of fun and games with embedded periods which can be overridden by [bracketing it], but you'll find out about that as you go along.)
I would recommend that you use a free management studio tool called "SSMS Tools Pack" from Mladen Prajdic. It has a feature called SQL snippets where you can map snippets of SQL code to predefined keystrokes ("ssf" + ENTER" will do what you want using the tool).
I use it every day at different clients and its part of my SQL toolkit. Check it out here: www.ssmstoolspack.com.
Eric