powershelldba.de

SSMS Productivity: Template Explorer, Code Formatting, and Block Edit

None of these three sit on a toolbar button, none of them show up in a "What's new" banner, and most DBAs who've used SSMS for years have never touched one of them. All three are still in the box.

Template Explorer — Stop Retyping CREATE Statements

Open it with Ctrl+Alt+T, or View → Template Explorer. It's a tree of ready-made T-SQL scripts, organized by category — database, table, index, trigger, stored procedure, SQL Server Agent job, linked server, and more — each one a starting point instead of a blank query window.

What makes them more than a snippet library is the placeholder syntax: <parameter_name, data_type, default_value>. A template drops these placeholders wherever a real value belongs:

CREATE TABLE <table_name, sysname, table_1>
(
    <column_name, sysname, column_1> <data_type_for_column, , int>
)

Open the template, then press Ctrl+Shift+M (or Query → Specify Values for Template Parameters). One dialog lists every placeholder in the script; fill each in once and every occurrence gets replaced together — no hunting through the script for the second and third place a name needs to change.

Build your own. Right-click a category in Template Explorer → New → Template (or right-click the top-level node → Open Containing Folder to find the physical .sql files and drop your own in directly). A rollout script you run every time you provision a new database — file groups, standard permissions, an audit table — becomes a template with your own placeholders exactly the same way the built-in ones work.

"Pretty Code" — What SSMS Actually Formats (and What It Doesn't)

SSMS has real formatting commands under Edit → AdvancedFormat Document and Format Selection, inherited from the underlying Visual Studio shell, bound to Ctrl+K, Ctrl+D and Ctrl+K, Ctrl+F. They're real, and they're worth knowing about.

They are not a T-SQL beautifier. Format Document normalizes whitespace and indentation based on the editor's own tab/brace settings — it will not break a 40-column SELECT list onto separate lines, align your JOIN conditions, or make a nested subquery readable. If that's what you're after, that's the territory of a dedicated formatter (SQL Prompt, Poor Man's T-SQL Formatter, and similar tools) — SSMS's native command was never built to do that job.

Two commands that punch above their weight, both chords under Edit → Advanced:

Block/Column Edit — Type Once, Apply to Every Line

Hold Alt and drag with the mouse, or hold Alt+Shift and use the arrow keys, and the selection becomes a rectangle instead of a run of text — a column or box selection. Type, and the same character lands on every selected line at once. Press Delete, and it deletes from every line at once.

The case that sells it: a list of table names, pasted from somewhere else, that all need a schema prefix.

Orders
Customers
Invoices
Products

Put the cursor at the very start of the first line, hold Alt+Shift, press Down three times to select a zero-width column spanning all four lines, then type dbo.:

dbo.Orders
dbo.Customers
dbo.Invoices
dbo.Products

One insertion, four lines updated. The same trick removes a common prefix, indents a block by a fixed number of spaces, or turns a plain list into a DROP TABLE script line by line.

Uneven line lengths? A column selection is a rectangle, so it naturally stops at whatever column you started it in — fine for prefixing, awkward for appending when lines differ in length. Alt+Shift+End extends the selection to the actual end of every included line, however long each one is, so you can append instead of only prepend.

Where Each One Actually Saves Time

Feature Best for Shortcut
Template Explorer Starting a DDL/admin script from a consistent, parameterized skeleton instead of a blank window or your memory Ctrl+Alt+T · fill values with Ctrl+Shift+M
Format Document/Selection Whitespace/indentation cleanup, and fixing keyword casing across a whole script in one pass Ctrl+K,D / Ctrl+Shift+U
Block/column edit The same small edit repeated down a list of lines — prefixes, indentation, turning a list into statements Alt+drag or Alt+Shift+arrows

Best Practices

The Bottom Line

None of these three replace a real tool built for the job — Template Explorer isn't a scaffolding generator, Format Document isn't SQL Prompt, and block edit isn't a scripting language. What they are is already installed, already free, and already three keystrokes away the next time a script starts from nothing, needs its casing fixed, or turns into the same one-line edit repeated down a list.