Alternatives · Basic Logics · Did you Know! · Keyboard Shortcuts · Play in SQL · Real Scenario Logic's

Little Trick to Save Time in SSMS

Little Drops of Ink make Millions to Think!

Introduction

In this blog post, we are going to see a little trick that saves our valuable time in SSMS.

Actually, if we need to change , include , remove or select a pattern in our SQL code or SQL scripts, most of us follow some of the methods like

  • Manually going to each lines and does changes(not helpful for huge numbers)
  • Copy/Paste our Codes and do Excel works(for small numbers-it is not helpful; for huge numbers-it takes most of our time; Also we need to know Excel skills)

But 1 trick is there in SSMS itself and it works fine for both small and high number of lines. Also we don’t need Excel Skills for this and it also saves our time.

What it is?

Please follow the below 6 images for easy understandings (Explanation added in images itself!)

Dummy SQL Script – (Use the below A to Z Script To try!)

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

Images with Explanation

By two ways, we can try this.

  • One is Alt + Mouse Click and Drags
  • Another method is Keyboard Shortcut Alt + Shift + (Up,Down,Left,Right Arrows)

NOTE –

At any position (Front, Middle or End), we can apply/use this trick. we can select, include, remove and modify dragged content/code using this trick in SSMS (SQL Server Management Studio).

It is not useful, if scripts are NOT STRAIGHTLY ALIGNED like below pic.

NOT STRAIGHTLY ALIGNED

Real Life Scenario

Practical Advantage of this trick aka., one of the use case scenario is,
We can Drop Multiple Tables in a Single Query in SQL Server.

Here, say for example we need to delete some 20 dummy tables. we already have all those table’s name lists. Before we can add drop table syntax. But every line We need to add comma ‘,’ . Here, we can use this trick(at Front) in SSMS itself and save lot of our time.

Conclusion

Since this is related to SSMS Feature, it works fine in both Azure SQL DB and On-Premises. Unit Tested in both environments.

The Special Thanks to my colleagues (Alveena Joyce and Kapilaguru Avani) who were behind the reasons for this Little Trick post!

Related blog posts

Follow Blog and Show your Support for many more interesting upcoming Posts!

Advertisement

One thought on “Little Trick to Save Time in SSMS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s