Wednesday, August 25, 2021

How to select and change multiple lines in SSMS (SQL Server Management Studio Tips)

Many times we copy Id, names and other attributes form Excle file, email or from other query result which doesn't have single quotes on it. In order ot add single quotes to make it Sring in SQL Server mangaement studio, you are left with no opiton but to manually add single quotes before and after stirng and comma between two values. This is ok if you have just couple of values but if you have 50 or 100 then you are screwed. Today I come to know about an excellent SSMS shortcut, which will let you change multiple lines at once, what this means is that you can add single quotes at front of those 50 values in one keystroke, provided they are in different lines. THis will save a lot of time while working wtih SQL Server, 


I used to make a cab in excel, then open in notepad, and copy+paste. This will save so much more time.


here is this tip in action :

https://www.reddit.com/r/SQL/comments/39lfaf/i_just_learned_about_altshift_in_ssms/


I knew about ALT to select a column of text but I didn't know you could snap like that with shift. It also works in Visual Studio and Notepad++

It is indeed real, and other good text editors supports this action as well. I use it everyday in Visual Studio for example.


Neat trick, but it only works if all the items in your list are the same size like the GUIDs in your example, hat's a bummer. At least it'll always work on the left side.


You can also alt-mouse move for box selecttions.


It also works in conjunction with ctrl and the arrow keys and pageup/down and home/end.

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.