You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add sqlcmd open vscode and sqlcmd open ssms commands
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.
Use `sqlcmd --help` to view all the available sub-commands. Use `sqlcmd -?` to view the original ODBC `sqlcmd` flags.
75
74
75
+
### Connect using Visual Studio Code
76
+
77
+
Use `sqlcmd open vscode` to open Visual Studio Code with a connection profile configured for the current context:
78
+
79
+
```
80
+
sqlcmd open vscode
81
+
```
82
+
83
+
This command will:
84
+
1.**Create a connection profile** in VS Code's user settings with the current context name
85
+
2.**Copy the password to clipboard** so you can paste it when prompted
86
+
3.**Launch VS Code** ready to connect
87
+
88
+
To also install the MSSQL extension (if not already installed), add the `--install-extension` flag:
89
+
90
+
```
91
+
sqlcmd open vscode --install-extension
92
+
```
93
+
94
+
Once VS Code opens, use the MSSQL extension's Object Explorer to connect using the profile. When you connect to the container, VS Code will automatically detect it as a Docker container and provide additional container management features (start/stop/delete) directly from the Object Explorer.
95
+
96
+
> **Note:** For remote servers that use password-based (basic) authentication, use `sqlcmd open ads` instead. The `open vscode` command only supports password-based auth for local containers. Passwordless auth (Windows integrated, AAD) works for all contexts.
97
+
98
+
### Connect using SQL Server Management Studio (Windows)
99
+
100
+
On Windows, use `sqlcmd open ssms` to open SQL Server Management Studio pre-configured to connect to the current context:
101
+
102
+
```
103
+
sqlcmd open ssms
104
+
```
105
+
106
+
This command will:
107
+
1.**Copy the password to clipboard** so you can paste it in the login dialog
108
+
2.**Launch SSMS** with the server and username pre-filled
109
+
3. You'll be prompted for the password - just paste from clipboard (Ctrl+V)
110
+
111
+
> **Note:** For remote servers that use password-based (basic) authentication, use `sqlcmd open ads` instead. The `open ssms` command only supports password-based auth for local containers. Passwordless auth (Windows integrated, AAD) works for all contexts.
112
+
76
113
### The ~/.sqlcmd/sqlconfig file
77
114
78
115
Each time `sqlcmd create` completes, a new context is created (e.g. mssql, mssql2, mssql3 etc.). A context contains the endpoint and user configuration detail. To switch between contexts, run `sqlcmd config use <context-name>`, to view name of the current context, run `sqlcmd config current-context`, to list all contexts, run `sqlcmd config get-contexts`.
0 commit comments