I spend a lot of my day in SSMS. It’s highly customisable with plenty of tools and shortcuts to make life easier. These are just a handful of the options available that I find most useful.
1 – Create a list of comma-separated columns
If you want a comma separated list of all columns from a table in your query window, you can do this by dragging the ‘Columns’ item in Object Explorer and dropping it onto to a query window.
2 – Use the query window to edit side by side
By clicking on the query header and selecting ‘new vertical group’ you are able to then edit two queries side by side. Both queries can then be scrolled and edited independently.
3 – Use the keyboard shortcuts
Using the shortcuts instead of pointing and clicking you can work faster and spend more time writing queries.
These are the shortcuts I find handy:
– F5 – Execute currently selected code
– CTRL + R – Show/hide the results pane
– CTRL + N – Open a new query window
– CTRL + L – Display the query execution plan
4 – Displaying line numbers
Enabling line numbers makes it easier to find where the problems are when SSMS throws you an error. This is especially useful when you’re working with long queries. To turn this on go to:
Tools > Options > Text Editor > Transact-SQL > tick the Line numbers box.
5 – Moving columns in the results pane
If you have lots of columns in your result set and want to change their order in the grid view without having to rerun the query. Simply drag the column headers and drop them in your preferred order.
6 – Open a new query window on start up
When this option is turned on SSMS opens up a new Query window once you are connected. To turn this on go to:
Tools > Options > Environment > Start up > select the Open new query window option.
7 – Adding commas to a list in one step
Instead of manually adding commas or quotes between a list of columns or strings you can do this all in one go by using Alt + C.
Hold the two keys down as you click where you’d like to start and you should see a faint line appear. Drag this down to where you’d like to start editing and make your changes. This can also be used for deleting in one step.
8 – Select a colour for each environment you use
If you are in multiple environments each day you may find it useful to have a different colour for each connection – pink for UAT, blue for Dev, red for Prod indicating where you should be cautious. On startup go to:
Options > Connection Properties > Use custom colour.
9 – Use this performance reports
Instead of trawling through scripts you can use the standard SSMS performance and troubleshooting reports. The information is presented in graphs and tables so you don’t have to do anything else to make them user-friendly. To access the reports, right click on the database you’re interested in:
Reports > Standard Reports > Pick your report.
10 – Filter objects in Object Explorer
Searching for an object with a specific name? You can filter objects to make finding it easier. Expand the database you’re interested in:
Tables > Right click > Filter > Filter Settings.
From here you can filter by name.
To clear the filter, right-click Tables, and then select Remove Filter.