Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Prompt Helper

Redgate SQL Prompt-style productivity for VS Code, built on top of the mssql and PostgreSQL extensions — it does not replace them. Keep connecting and running queries with those extensions; this one adds three things:

1. Opinionated formatting

Shift+Alt+F (Format Document) or Format Selection on any .sql file:

SELECT
    c.CustomerID
    ,c.FirstName
    ,c.LastName
FROM dbo.Customer c
WHERE c.IsActive = 1
  • Leading commas (default) or trailing, uppercase keywords/types/functions, 4-space indent — all configurable under Settings → SQL Prompt Helper.
  • T-SQL GO batch separators are preserved.
  • The dialect is detected from the owning extension (mssql → T-SQL, pgsql → PostgreSQL).
  • If a script cannot be parsed, the document is left untouched (see the SQL Prompt Helper output channel).

To make it the default SQL formatter:

"[sql]": { "editor.defaultFormatter": "datht.sql-prompt-helper" }

2. Quick DDL — ALTER PROC expansion

In a connected SQL Server editor, type:

ALTER PROC <start typing a name...>

Suggestions are read from the connected database. Accepting one replaces the fragment with the full current definition of the procedure, rewritten from CREATE to ALTER. Also works for ALTER FUNCTION, ALTER VIEW, ALTER TRIGGER, and CREATE OR ALTER ....

3. Quick DML — INSERT expansion

In a connected SQL Server editor, type:

INSERT <start typing a table name...>

Accepting a table generates the whole statement with every writable column (identity, computed, generated, and rowversion columns are skipped), with snippet tab-stops on each value and type hints as comments:

INSERT INTO dbo.Customer
    (
     FirstName
    ,LastName
    ,Email
    )
VALUES
    (
     FirstName -- nvarchar(50), not null
    ,LastName -- nvarchar(50), not null
    ,Email -- nvarchar(255)
    )

Requirements & permissions

  • DB-backed completions require the mssql extension ≥ 1.30 and a connected editor. On first use, the mssql extension shows a one-time prompt asking you to Approve "SQL Prompt Helper" accessing your connections (manage later via the MS SQL: Edit Connection Sharing Permissions command).
  • The PostgreSQL extension (1.28) exposes no public query API yet, so for Postgres documents you get the formatter only; completions light up automatically once that extension ships connection sharing.
  • Metadata is cached (default 120 s). Run SQL Prompt Helper: Refresh Schema Cache after changing schema.

Settings

Setting Default Description
sqlPromptHelper.format.commaStyle leading leading or trailing list commas
sqlPromptHelper.format.spaceAfterLeadingComma false ,col vs , col
sqlPromptHelper.format.keywordCase upper keyword casing
sqlPromptHelper.format.dataTypeCase upper data type casing
sqlPromptHelper.format.functionCase upper built-in function casing
sqlPromptHelper.format.tabWidth 4 indent width
sqlPromptHelper.format.useTabs false tabs instead of spaces
sqlPromptHelper.format.expressionWidth 60 max inline expression width
sqlPromptHelper.format.linesBetweenQueries 1 blank lines between statements
sqlPromptHelper.completions.enableDdlExpansion true ALTER expansion
sqlPromptHelper.completions.enableInsertExpansion true INSERT expansion
sqlPromptHelper.completions.insertColumnTypeComments true -- type hints in VALUES
sqlPromptHelper.schemaCacheSeconds 120 metadata cache lifetime

Development

npm install
npm run typecheck   # tsc --noEmit
npm test            # formatter unit tests (plain Node)
npm run build       # bundle to dist/extension.js
npm run package     # produce .vsix

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages