Query shortcuts are one of the great features in SSMS (SQL Server Management Studio) that is commonly overlooked. One of my favorite query shortcuts for TSQL development is the ability to select all records from a table, by simply by highlighting the table name and pressing Ctrl+F1. In this two part blog post series I will demonstrate how to setup a couple variations of my favorite query shortcut.
Simple Query:
In order to setup a query short cut you will need to navigate to the SSMS Options Dialog:
(SQL 2012)
- Open SSMS navigate to Tools –> Options…
- After the dialog opens navigate to Environment –> Keyboard –> Query Shortcuts. This will open the Options dialog window shown below.
- Enter “SELECT * FROM ” in any of the open text fields under Stored Procedure.
- Click [OK]
NOTE: The new query shortcut will be available in all SSMS windows opened after the query shortcut is saved.
Now open any query highlight any table name and press Ctrl+F1. Voila you have the contents of the highlighted table. Below we are looking at a snippet of the [dbo].[uspGetEmployeeManagers] procedure in the adventure works database.
Notice that the schema is selected as a part of the table name. In part 2 of the Query Shortcuts I will demonstrate another approach where the schema does not need to be highlighted. Also we will use a stored procedure rather than a query.