Langsung ke konten utama

How to BLOCK Select SSMS

SQL Server Management Studio has so much capability, yet most people I meet don’t seem to have read the manual to discover it.
So I thought I might post a few of features I find invaluable. This works for SQL 2005, SQL2008, SQL2008 R2 & Visual Studio.
Summary:
Tip 1: It is possible to “ALT + Select” to highlight a block of text to work on.
Tip 2: If you press ALT & stay in the same column (vertical line), it doesn’t select a block but instead selects an entire line, not just the partial top & partial bottom lines.
The following is a quick example of what I mean plus a few other uses you may not have thought of.

Example:
Tip 1: It is possible to “ALT + Select” to highlight a block of text to work on. eg: Hold the ALT key, Left Click & move your Mouse produces the Blue “Selected” region in picture below. You must press ALT prior to moving the mouse.
 image
If I hit DELETE, then I remove just those characters so they all line up next to the NVARCHAR.
image
Just for comparison. If I just Click & Drag down without the ALT. I’d see all the lines selected. Starting from the Character I clicked on at the start line & finishing on a partial line I released the mouse.
image
Tip 2: If you press ALT & stay in the same column (vertical line), it doesn’t select a block but instead selects an entire line, not just the partial top & partial bottom lines. eg:
image

Other Uses:
1. Block Select an area of code to limit the effects of other commands.
eg: using CTRL+ALT+U to convert all selected text to Upper case.
image
image
2. Same can be done for :-
i) Search & Replace within a small area, 
ii) Copying a column of Text next to itself & 
iii) many other uses.

The following is somewhat contrived example of building really large WHERE clauses. The sort of TSQL you might create if you wanted to compare every row in the table with every row in the same table in a different database. Some people may do this when they are rewriting stored procedures & need to check that the new code gives the same result as the old code. Of course they’d use a FULL OUTER JOIN to ensure they noticed if they Deleted or Inserted any extra rows. (Clearly the data comparison feature in Visual Studio for Database Professionals is way faster & less error prone but not everyone has installed it.)   eg:
Step A: Create a large table, using SSMS “Script AS” or “SELECT Top N Rows” is handy for this.
 image image
Step B: ALT+Select the Column of  info you want & Paste it in the WHERE / ON Clause area.
image image
Step C: Repeat but this time grab some Whitespace to push the rows to the right, which ensures the code still lines up so you have a vertical area you can conveniently select.
image image
 Step D: Cut the Column names again & Paste to the left of themselves.
image image
Step E: Highlight one of the columns & use Find & Replace, just to change values in the Highlighted area. eg: Remove the comma “,” & replace with an Equal & Table Alias “= R.”
 image image image
Step F: Repeat above but this time Swap the comma for a Join Clause & Table Alias “ AND F.”  (Yes I also swapped the “WHERE” to an “ON” & added the 3 part table names)
 image image
Step G: Use some of the Advanced Editing Commands to tidy it up. eg: Delete Horizontal White Space ( Hit Ctrl K, then Ctrl \ ) & “Increase Indent” button.
 image image
Kind of a long post for such a simple feature. I hope the pictures stimulate your thinking in the wide variety of ways this can change the way you work.
enjoy

Komentar

Postingan populer dari blog ini

Totolink N300RT

Panduan singkat install OpenWrt Totolink N300RT Download FrmUpg :  http://www.anphat.vn/download/FirmwareUpgradeTool.zip Putty : http://www.putty.org/ Frimware totolink v2.1.6 :  http://www.totolink.net/include/download.asp?path=down/010300&file=N300RT-V2.1.6_20160516.zip Bootloder boot96E_32M:  https://drive.google.com/open?id=1p0SreEifzElS_cyngZZRL2lmGnR-Mvvi OpenWrt  :  https://drive.google.com/open?id=1ykv6QkrqXJ_8vnX-6imib44XGFVNJZoA A. Downgrade Frimware Totolink ke v2.1.6 Dalam router dalam keadaan mati tekan Tombol Reset lalu hidupkan power. tunggu sampai lampu indikator lan berkedip. Matikan Firewall dan Buka FrmUpg.exe dan colokan LAN ke Port 1,2,3,4 Di Frimware File pilih file Totolink v2.1.6 dan klik send, Tunggu sampai prosess selesai lalu restart router, cek 192.168.1.1 apakah sudah berhasil downgrade. B. Upgrade OpenWrt Ulangi langkah no 1, Pilih file bootloder boot96E_32M. klik send. tunggu sampai selesa...

How to customize tab colors in SSMS

Applies to ApexSQL Complete Summary This article describes how to set a custom connection color to a query tab in Microsoft  SQL Server Management Studio  (SSMS) using a feature called  Tab coloring  in ApexSQL Complete. Description Tab coloring can set custom connection colors for individual instances of SQL Server, down to the database level. The user has ability to assign SQL servers, and databases to a specific environment to help quickly identify which connection a tab is currently using.

DemoHelper tool buat Coret-coret Layar Komputer

Salah satu tool untuk membatu presentasi.  Sample : Zooming Mode up zooms in down zooms out enter or left mouse click activates drawing of the zoomed area escape cancels zooming mode Zooming is also possible using the mouse wheel. Drawing Mode up/down or Ctrl+Mousewheel increases/decreases the size of the drawing brush right or Mousewheel cycles through the available brush colors 0-9 select the brush colors Shift while drawing forces horizontal/vertical drawing Control while drawing drawing straight lines right mouse-drag draws arrow lines right mouse-drag with control key pressed draws straight lines escape quits drawing mode backspace removes the last line drawn delete removes the first line drawn E removes all drawn lines M toggles the marker on/off T toggles between solid and merged drawing Z select a rectangle to zoom in C clears the screen with the background color