Skip to content

feat: add sqlcmd open vscode and sqlcmd open ssms commands#688

Open
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:pr-685
Open

feat: add sqlcmd open vscode and sqlcmd open ssms commands#688
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:pr-685

Conversation

@dlevy-msft-sql
Copy link
Copy Markdown
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Feb 1, 2026

Problem

sqlcmd open ads is the only tool-launch command, but Azure Data Studio is deprecated and no longer the primary tool for SQL Server development.

Solution

Add sqlcmd open vscode and sqlcmd open ssms commands alongside the existing sqlcmd open ads.

Changes

Area Change
cmd/modern/root/open/vscode.go VS Code command: creates connection profile in mssql.connections, launches via vscode:// URI
cmd/modern/root/open/ssms.go SSMS command (Windows): tries ssms://connect URI for remote servers, falls back to direct exe launch with -C for local containers
cmd/modern/root/open/jsonc*.go JSONC parser and patcher: preserves comments/trailing commas in VS Code settings.json
cmd/modern/root/open/clipboard.go Shared clipboard-based password transfer (VS Code sandboxes creds; SSMS 18+ removed -P)
cmd/modern/root/open/uri_*.go OS protocol handlers (
undll32/open/xdg-open) shared by both commands
internal/tools/tool/vscode*.go VS Code tool discovery across Windows/macOS/Linux (user + system installs, Insiders priority)
internal/tools/tool/ssms*.go SSMS tool discovery with dynamic version-sorted path scanning
internal/pal/clipboard*.go Cross-platform clipboard (clip/pbcopy/xclip/xsel/wl-copy)
internal/tools/tool/tool.go ExePath(), RunWithOutput(), error instead of panic on unchecked IsInstalled()
README.md Updated quickstart with VS Code and SSMS examples

Design Decisions

  • URI-based launch: Both commands use OS protocol handlers (vscode://, ssms://) rather than direct exe launch where possible. This avoids hardcoding paths and works with multiple installed versions.
  • SSMS local connection fallback: The ssms:// protocol handler has no -C (trust server certificate) mapping, so local container connections skip the URI path and launch SSMS directly with -C for self-signed cert support.
  • JSONC preservation: VS Code settings.json supports comments and trailing commas. The JSONC patcher replaces only the mssql.connections value, preserving all other formatting and comments byte-for-byte.
  • Clipboard for passwords: VS Code uses sandboxed credential storage (no API to inject passwords). SSMS 18+ removed the -P flag. Clipboard is the common denominator.

Testing

  • 45 tests across cmd/modern/root/open/..., internal/tools/..., internal/pal/...
  • JSONC parser/patcher: comments, trailing commas, real-world VS Code settings
  • Tool discovery: SSMS version extraction, path scanning
  • Profile management: create, update, dedup
  • Manual testing: sqlcmd open vscode (confirmed working), sqlcmd open ssms (confirmed working)

Supersedes #685. Fixes #584.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for opening Visual Studio Code and SQL Server Management Studio (SSMS) to work with SQL Server connections managed by sqlcmd, addressing the deprecation of Azure Data Studio. The implementation uses clipboard-based password sharing since both tools use sandboxed credential storage.

Changes:

  • Adds sqlcmd open vscode command that creates connection profiles in VS Code settings and auto-installs the MSSQL extension
  • Adds sqlcmd open ssms command (Windows-only) that launches SSMS with pre-configured connection parameters
  • Implements cross-platform clipboard support for secure password sharing
  • Includes comprehensive tests and documentation updates

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/modern/root/open.go Updates open command to include VSCode and SSMS subcommands
cmd/modern/root/open/vscode.go Main VSCode command implementation with settings file manipulation
cmd/modern/root/open/vscode_*.go Platform-specific VSCode implementations
cmd/modern/root/open/ssms.go Main SSMS command implementation
cmd/modern/root/open/ssms_*.go Platform-specific SSMS implementations (Fatal on non-Windows)
cmd/modern/root/open/clipboard.go Helper function for clipboard-based password sharing
cmd/modern/root/open/*_test.go Comprehensive test coverage for new commands
internal/tools/tool/vscode*.go VSCode tool detection and configuration
internal/tools/tool/ssms*.go SSMS tool detection and configuration
internal/pal/clipboard*.go Cross-platform clipboard implementation using native APIs
internal/tools/tools.go Registers VSCode and SSMS tools
README.md Adds clear documentation with usage examples
.gitignore Adds /modern build artifact

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 31 changed files in this pull request and generated 9 comments.

Comment thread cmd/modern/root/open/ssms_unix.go
Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode_test.go Outdated
Comment thread cmd/modern/root/open/ssms_test.go Outdated
Comment thread cmd/modern/root/open/ssms_darwin.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 33 changed files in this pull request and generated 3 comments.

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread internal/tools/tool/vscode_linux.go
Comment thread README.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/ssms.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 4 comments.

Comment thread internal/tools/tool/tool.go Outdated
Comment thread cmd/modern/root/open.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.

Comment thread internal/pal/clipboard_linux.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated no new comments.

@dlevy-msft-sql dlevy-msft-sql force-pushed the pr-685 branch 3 times, most recently from 74dc09d to b64f990 Compare February 5, 2026 19:40
@dlevy-msft-sql dlevy-msft-sql changed the title Add sqlcmd open vscode and sqlcmd open ssms commands feat: add sqlcmd open vscode and sqlcmd open ssms commands Feb 5, 2026
@dlevy-msft-sql dlevy-msft-sql force-pushed the pr-685 branch 3 times, most recently from dd1141d to 675a0df Compare February 6, 2026 00:34
@dlevy-msft-sql dlevy-msft-sql force-pushed the pr-685 branch 7 times, most recently from fa27800 to f2b4a78 Compare April 23, 2026 21:19
Add 'sqlcmd open vscode' and 'sqlcmd open ssms' subcommands that launch
VS Code or SSMS pre-configured with the active sqlcmd context's connection.

VS Code integration:
- Creates/updates mssql.connections in VS Code settings.json
- Preserves JSONC comments via surgical byte-level patchJSONCKey
- Atomic temp-file-then-rename write to prevent corruption
- Copies password to clipboard with security warning

SSMS integration:
- Launches SSMS with connection parameters via command line
- Windows-only with platform stub for Unix

Includes clipboard helpers, JSONC parser/patcher, platform abstractions,
and comprehensive tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: S Small issue (less than one week effort) SSMS vscode-mssql-ext

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove ADS and add support for VSCode + MSSQL

2 participants