Handy Trick in SSMS
Published: 30th May 2015
This is a quick post about something I only found out recently and which has made my life so much easier in many circumstances. It’s something I also imagine you’ll soon use a lot too if you don’t already.

It’s basically a solution to a problem that we all face in which we end up having to perform multiple copy and pastes or the repetitive “comma, down arrow, comma, down arrow…” scenario.

So what’s the feature? Well it’s simply holding SHIFT and ALT down whilst using the arrow keys to move your cursor up and down.

This allows you to write on multiple lines at once.

Confused? Okay, here’s a quick (very fabricated) demo:

use AdventureWorks2012
go

select top 10 name
from sys.tables
where schema_id('sales') = schema_id


Okay, so now we have this we want to do a quick top 1 from each table in our output.

Now, we could of course have written our select to output that command, but that’s not the point here and that can easily get very complicated and sometimes isn’t the best idea.

So… copy and paste the results into SSMS:

Now, place your cursor at the start of the first record (in this case “ShoppingCartItem”). Now, hold SHIFT and ALT and press the down arrow key. You’ll see a grey line being drawn down all the rows:

If you look carefully you’ll see it there… now just start typing and it will appear on each line:

And there you have it… REALLY fast, saves on copy and paste, and works in a LOT of otherwise tedious scenarios. Enjoy!!!

Comments:
NB: Comments will only appear once they have been moderated.