Tip - SQL Server Management Studio - Reorder Lines
[SQL Server, SQL Server Management Studio, Tips]
Most of your time when working with the SQL Server Management Studio you will be writing and modifying queries.
A common scenario is you want to move around the lines in a query.
So assuming we have this query:
SELECT
Countries.CountryID,
Countries.Name,
Countries.Code,
Countries.EditUserID,
Countries.DateModified,
Countries.CreateUserID,
Countries.DateCreated,
Countries.Approved,
Countries.ApprovedUserID,
Countries.DateApproved
FROM
dbo.Countries;
If we want to change the order of Name and Code we would have to:
- Highlight the row with Code
- Cut (
Ctrl + C
) - Move the cursor up ⬆
- Press Enter
- Paste (
Ctrl + V
) - Move the cursor 2 lines down ⬇⬇
- Delete the blank line ❌
Alternatively, you can hold down ALT
and move the current line with the cursor up ⬆ or down ⬇ with the keyboard arrows.
Like so:
Lightning fast.
Happy hacking!