Skip to content

User's Guide

StyleSQL is a SQL formatter that integrates directly into SQL Server Management Studio (SSMS). It helps you format T-SQL code consistently, whether you're working in the editor or batch-formatting an entire database. Use it to enforce team standards, clean up legacy code, or ensure consistent output before commits.

This guide provides an overview of StyleSQL's features and user interface. For quick-starts, see Getting Started. For details, explore the Features section.

Formatting in the Editor

StyleSQL offers flexible ways to format SQL as you edit in the SSMS query window.

Manually format SQL in editor

Manually format the current selection or entire script in the editor.

  • What it is: Right-click in the editor and choose "Style SQL in Editor", or use the toolbar button for one-click formatting.
  • Why use it: Quick, manual control over formatting without auto-triggers. Ideal when you want to format only specific sections or verify output before committing.
  • Keyboard shortcut: Ctrl+K, Ctrl+F
  • For details: See Format in Editor.

Auto-format on Paste

Automatically format SQL whenever you paste it into the editor.

  • What it is: Toggles via toolbar or Settings to format pasted content immediately.
  • Why use it: Ensures external SQL (from teammates, docs, etc.) matches your style without manual intervention.
  • For details: See Auto-format on Paste.

Auto-format on Execute

Automatically format your SQL right before execution in SSMS.

  • What it is: Ensures consistent formatting on execution.
  • Why use it: Maintain standard formatting on queries without changing your working habits.
  • Related toggles: DDL only (limit to CREATE/ALTER scripts); Restore original (only format the code going into the database; leave your text in your editor unformatted). Configure both in Settings.
  • For details: See Auto-format on Execute.

Customizable Formatting

Choose formatter engines and configure options to match your team's style.

  • What it is: Select ScriptDom, PoorSQL, or sql-formatter; adjust indentation, casing, and more.
  • Why use it: Tailor output to your conventions (e.g., UPPERCASE keywords, specific indent sizes). Share settings across teams via settings.json.
  • For details: See Customizable Formatting.

Formatting the Entire Database

Batch-format all objects in a database with review and safety controls.

Batch Format Database

Format every stored procedure, view, function, and trigger in a database at once.

  • What it is: Open from Object Explorer (right-click database → "Style Database"), scan objects, review diffs, generate ALTER scripts.
  • Why use it: Quickly bring legacy databases up to standards, enforce consistency across teams, or clean up after migrations.
  • Safety features: Diff-first workflow, selective object inclusion, script-only mode for manual review.
  • For details: See Batch Format Database.

User Interface Elements

Context Menu (Editor)

Right-click in the SSMS query editor for these options:

  • Style SQL in Editor — Format current selection or document.

Context Menu (Object Explorer)

Right-click a database node in Object Explorer:

  • Style Database — Open the batch formatting window and scan the database.

Editor toolbar

  • Style SQL in Editor — Format current selection/document.
  • Style on Execute — Auto-format on query execution.
  • Style on Paste — Auto-format pasted content.
  • Settings — Open configuration window.
  • About — Access version and update info.

Tools menu

  • Top menu: Tools → StyleSQL
  • Contains the same actions as the editor toolbar:
    • Style SQL in Editor
    • Style on Execute
    • Style on Paste
    • Settings
    • About

Style Database window

  • Top: Toolbar with options
  • Left pane: tree view of detected objects (procedures, views, functions, triggers)
  • Right pane: diff viewer showing before/after formatting for the selected object
  • Bottom: Status bar with operation progress and button to open log panel

Style Database toolbar

  • Rescan — Re-run with current filters.
  • Select All / Select None — Bulk-select in the tree.
  • Expand All / Collapse All — Expand or collapse the object tree.
  • Script Only — Generate a T‑SQL script without executing.
  • Side-by-side — Toggle diff layout (side‑by‑side vs inline).
  • Ignore whitespace — Hide whitespace-only differences.
  • Changes only — Collapse unchanged sections around edits.
  • Apply — Generate the script.
  • Cancel — Stop the current operation.
  • About — View version/update info.

Settings and About Window

  • Settings Window — Configure formatters, options, exclusions, and UI behavior. Saved to %AppData%/StyleSql/settings.json.
  • About Window — Shows current version, button to check for updates, button to open the error log folder.

Settings and persistence

  • Options are saved to %AppData%/StyleSql/settings.json and reloaded automatically.
  • Configure indent size, keyword casing, exclusions, and more.
  • Editor integration toggles: Style on Execute and Style on Paste are available via Tools menu and toolbar.

Troubleshooting

  • Missing Style Database menu item — ensure you right‑click a database node (not server/folder nodes).
  • Nothing happened on Apply — ensure objects are checked and Script Only is enabled; look for the script in the editor and check the log panel.
  • Check logs / contact — Use About → Open error log folder to inspect logs. If you need help, email your log or a description of the issue to [email protected].

FAQ

  • Does StyleSQL change my scripts' behavior? No. It formats the text and leaves logic untouched.
  • Which SQL Server versions are supported? ScriptDom covers versions 80 through 170; Auto queries the connected server for the best fit.
  • How are line endings handled? StyleSQL converts to CRLF when writing scripts.
  • Can I revert settings I've customized? Changed values show in bold; change them until they're no longer bold to reset them to defaults, or delete the settings file to regenerate defaults all at once.
  • Why are some objects skipped during a Style Database scan? The Style Database window lists Skip Reasons when an object can't be styled. Objects created WITH ENCRYPTION appear as “Encrypted,” and extremely large modules (over 64 MB) show “Definition exceeds 64 MB limit.” Those objects stay untouched; everything else in the scan continues normally.
  • Why does ALTER appear uppercase even with the formatter configured to produce lowercase keywords? SQL Server stores object definitions internally with an uppercase CREATE regardless of the casing used when you alter an object. When StyleSQL generates scripts, it plays along and replaces that stored CREATE with uppercase ALTER so that subsequent scans compare equal and don’t trigger false positives or unnecessary reformatting.