Use F5 To Execute A Query In Visual Studio


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:

  1. From the Tools Menu select “Customize”.

  1. In the Customize window click the “Keyboard” button.

 

 

  1. Now here’s where the action is! Type “exec” into the “Show commands containing” box.
  2. Select “Data.SqlEditorExecuteSql” in the list box below where you typed “exec”.
  3. Select “Transact-SQL Editor” in the “Use new shortcut in:” dropdown.
  4. Set the cursor in the “Press shortcut keys:” box and press “F5”.
  5. IF YOU SKIP THIS STEP IT WON’T WORK! Click the “Assign” button. (Yes, I’m speaking from experience).
  6. Click “OK”.
  7. 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?!?


Leave a Reply

Your email address will not be published.