Use the VS Code mssql extension or Azure Data Studio engine to open a secure, reusable connection to any Microsoft SQL Server.
VS Code is lightweight, cross-platform, and integrates Git, REST clients, and AI plug-ins—ideal for developers that write code and T-SQL in one place.
Install Microsoft SQL Server (on-prem or Azure), enable TCP 1433, and create a login with db_datareader permission on your ecommerce database.
Search for “SQL Server (mssql)” in the Extensions view, click Install, and reload VS Code.This adds the mssql
command palette items.
Press F1 → MS SQL: Connect. Choose “Create new connection”. Supply server name, authentication type, user, password, and optional database (e.g., ecommerce
).Save the profile so it appears in settings.json
.
Use :connect
at the top of a .sql
file::connect localhost\SQLEXPRESS -d ecommerce -U shop_user -P yourPassword! -l 30
Open a .sql
file, pick your connection in the Status bar, and press Ctrl+Shift+E (Run Query). Results appear in an editor-integrated grid and can export as CSV.
Create .vscode/settings.json
→ {"mssql.connections": [...]}
.Commit this file so teammates share credentials via environment vars or Azure Key Vault references.
Create multiple connection profiles (“Local-Dev”, “Staging-ReadOnly”, “Prod-Admin”).Select the needed profile from Status bar; VS Code remembers the last used one per workspace.
Grant only SELECT
on Customers
, Orders
, Products
, and OrderItems
when running analytics queries to avoid accidental data changes.
Install “SQL Formatter” or enable built-in formatter (editor.formatOnSave
) for consistent style in pull requests.
VS Code supports code
snippets or leverage Galaxy Collections so teammates endorse reusable ORDER reports without pasting SQL in Slack.
Check firewall, make sure SQL Browser is on, verify server name (e.g., localhost,1433
for default instance) and that TLS certificates are trusted.
.
No. The extension is free and open-source from Microsoft.
Yes. Use the server’s full name your-db.database.windows.net
, enable “Allow Azure services” firewall rule, and set encryption to required.
Separate statements with GO
. The Results window displays each set in its own tab.