In SSMS, how to add multiple aliases to tables using the ALT key
It's only a small thing, but … this blog shows how you can click and drag with the ALT key held down, then type to apply a table alias to lots of tables simultaneously.

Posted by Andy Brown on 23 March 2016

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Using the ALT key to add lots of SQL aliases at once

Sometimes it's the little things ... I'm indebted to Tobi from my course this week for this tip.  Suppose you have a query like this:


-- columns from the films table


FilmOscarWins AS 'Oscars',

FilmRunTimeMinutes AS 'Length'


tblFilm AS f

You want to prefix each of your columns with the alias you've given your table, to get:


-- columns from the films table


f.FilmOscarWins AS 'Oscars',

f.FilmRunTimeMinutes AS 'Length'


tblFilm AS f

Here's the clever way to do this!  Hold down the ALT key, then click and drag down the column names:

Selecting with ALT key

Hold down the ALT key and click and drag to select a line to the left of the column names to which you want to add an alias.


Type the table alias and a full stop in - anything you type will be inserted at the start of every selected line:

Typing prefix

Characters that you type are added to every selected line.


Trivial, but strangely satisfying! 

This blog has 0 threads Add post