If you’re coming to Visual Studio 2010 from SQL Server Management Studio you’re probably getting annoyed by the fact that pressing the F5 does not execute your SQL when using the T-SQL Editor window. Do not fear! Like the $6 Million Dollar Man, “we have the technology… Better… Stronger… Faster.” Instead of the three buttons required by VS 2010 (CTRL+SHIFT+E) a single button can do the job. Behold! F5!
Okay, sorry about that. Here are the steps:
- From the Tools Menu select “Customize”.
- In the Customize window click the “Keyboard” button.
- Now here’s where the action is! Type “exec” into the “Show commands containing” box.
- Select “Data.SqlEditorExecuteSql” in the list box below where you typed “exec”.
- Select “Transact-SQL Editor” in the “Use new shortcut in:” dropdown.
- Set the cursor in the “Press shortcut keys:” box and press “F5”.
- IF YOU SKIP THIS STEP IT WON’T WORK! Click the “Assign” button. (Yes, I’m speaking from experience).
- Click “OK”.
- Click “Close” in the “Customize” window.
That’s it! Now, in addition to CTRL+SHIFT+E, you can press F5 to execute your SQL queries allowing you to use the same shortcut between SQL Server Management Studio (SSMS) and Visual Studio 2010.
Note: This does mean you will no longer be able to press F5 to run the data generator but come on, how often are you really going to use that thing compared to executing SQL?!?