Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>MSSQL ExtrasNew to Visual Studio Code? Get it now.
MSSQL Extras

MSSQL Extras

erexer

|
120 installs
| (0) | Free
Extends the mssql extension with automatic IntelliSense cache refresh and server-aware color profiles that change VS Code UI colors based on which SQL Server database is active.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MSSQL Extras

A VS Code extension that extends the SQL Server (mssql) extension with quality-of-life features for working with multiple SQL Server environments.

Features

1. Automatic Cache Refresh

Before each query run, the extension calls mssql.rebuildIntelliSenseCache to invalidate mssql's cached schema metadata. This ensures that edits to stored procedures, views, and other objects are picked up immediately — no more executing a stale cached version of a procedure you just updated.

2. Server Color Profiles

VS Code's UI colors (status bar, title bar, activity bar, editor tabs) automatically change based on which SQL Server and database you are connected to. Use a red theme for production and a green theme for dev/test — so you always know at a glance which environment you are touching.

Colors update within ~300ms of switching databases via the mssql status bar, or as soon as you interact with the SQL editor. No query needs to be run.

Quick setup

Run the MSSQL Extras: Set Up Color Profiles command (or click the status bar item after connecting) to walk through the setup wizard. The wizard asks for:

  1. A server name pattern (e.g. *prod* or *)
  2. An optional database pattern (e.g. !*test* — see below)
  3. A color preset (red / amber / green / blue / dark / light)
  4. A friendly label shown in the status bar
  5. Whether to save to User Settings (applies everywhere) or Workspace Settings (shareable via git)

Manual setup

Add a mssqlExtras.serverColorProfiles array to your settings.json. Profiles are evaluated top-to-bottom; the first match wins.

"mssqlExtras.serverColorProfiles": [
  {
    "serverPattern": "*",
    "databasePattern": "*test*",
    "preset": "safe",
    "name": "Test"
  },
  {
    "serverPattern": "*",
    "databasePattern": "!*test*",
    "preset": "danger",
    "name": "Production"
  }
]

In this example:

  • Databases whose name contains "test" → green (safe)
  • Everything else (prod, staging, master, etc.) → red (danger)

Pattern syntax

Syntax Meaning Example
*prod* Contains "prod" (case-insensitive) Matches AdvWarehouseProd, PROD-DB
* Matches anything Catch-all
!*test* Does not contain "test" Matches AdvWarehouseProd, master — not AdvWarehouseTest
myserver.database.windows.net Exact match Azure SQL hostname
? Any single character server1, serverA

The ! prefix can be used on both serverPattern and databasePattern.

Verify your patterns

Run MSSQL Extras: Test Server Pattern while connected to see exactly which profiles match your current server/database and which would be applied.

Presets

Preset Color Use case
danger 🔴 Red Production
warning 🟡 Amber Staging / UAT
safe 🟢 Green Dev / sandbox / test
cool 🔵 Blue Reporting / read-only
dark 🌑 — Switch to Default Dark+ theme
light ☀️ — Switch to Default Light+ theme

Usage

Use the MSSQL Extras: Run SQL Query command to refresh the IntelliSense cache, update the active color profile, and delegate execution to mssql's native query runner.

Action Key
Run query (with cache refresh) Ctrl+Shift+R / Cmd+Shift+R

To use your existing Ctrl+Shift+E muscle memory, add this to your keybindings.json:

[
  {
    "key": "ctrl+shift+e",
    "command": "mssql-extras.runQuery",
    "when": "editorLangId == sql && editorTextFocus"
  },
  {
    "key": "ctrl+shift+e",
    "command": "-mssql.runQuery"
  }
]

Configuration

Setting Default Description
mssqlExtras.refreshCacheOnRun true Rebuild the IntelliSense/schema cache before each run
mssqlExtras.clearPooledConnections false Also clear pooled connections before each run (stronger, adds a brief reconnect delay)
mssqlExtras.enableServerColorProfiles true Enable automatic color profile switching
mssqlExtras.serverColorProfiles [] List of server-to-color mappings. First match wins.
mssqlExtras.defaultProfile null Profile applied when no pattern matches. null restores your normal theme.

Requirements

  • The SQL Server (mssql) extension (ms-mssql.mssql) must be installed and active.
  • You must be connected to a SQL Server instance in mssql before running a query.

First-run permission prompt

This extension uses the mssql Connection Sharing API to detect the active server and database for color profiles. On first use, mssql may show a one-time permission prompt:

"Allow 'MSSQL Extras' to access your database connection?"

Click Allow to enable automatic color profiles. This permission is stored securely and not asked again unless you revoke it. Query execution always uses mssql's native command and runs once.


How It Works

mssql-extras.runQuery
│
├─ 1. mssql.rebuildIntelliSenseCache          ← clears schema cache
│
├─ 2. evaluateColorProfile()                  ← apply colors for active server/DB
│
└─ 3. mssql.runQuery()                        ← executes query once and displays results

Color profile trigger (runs continuously while a SQL file is open)
│
├─ First connect (slow path):
│    connect() → SELECT @@SERVERNAME → cache by connection ID → disconnect()
│
└─ All subsequent checks (fast path, no SQL):
     getCachedServerName() + getActiveDatabase() → both in-memory, ~0ms
     300ms poll + editor selection events → detect DB switch instantly

Known Limitations

  • Color profile detection latency: Colors update within ~300ms of a database switch as detected by the poller. If the server name hasn't been cached yet (first run on a new connection), a background SQL query fetches it — this takes one round-trip (~50–200ms) and is cached for the rest of the session.

Building

npm install
npm run compile
npm test

To package as a .vsix:

npm install -g @vscode/vsce
vsce package --no-dependencies
code --install-extension mssql-extras-0.1.1.vsix --force

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft