Blog Post

Quick tip, ever needed to manipulate SQL on many lines in SSMS? now you can….

,

Have you ever had the need to select values that are directly on the next line down but drag-and-drop selects the entire line?

For example, if I need to copy all the highlighted values from the below SQL to form the basic of another statement:-

HighlightedSQL

Dragging and dropping would select all the SQL on every line which is wrong, see below:-

WronglyHighlightedSQL

To achieve this, put your cursor on the 1st instance of the column you need copying, in this example it is the value “13”.

Hold down ALT + SHIFT and press the DOWN arrow until you reach the last instance.

You can now press the RIGHT arrow until your text is highlighted:-

CorrectlyHighlightedSQL

You can now manipulate the selected text as you need, in my example i want to copy the IDs to use them in another statement:-

Completed

You can now use this method to write many lines of SQL with just one single line input. Just remember to hold ATL+SHIFT+DOWN ;)

Hope you found this useful?

Andrew

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating