Skip to main content

Microsoft SQL Server

pymssql-backed connector. db_type is mssql. Tier 2. Supports SQL Server 2016+, Azure SQL Database, and Azure SQL Managed Instance.

Connection config

sql server
{
"name": "prod-mssql",
"db_type": "mssql",
"host": "sqlserver.example.com",
"port": 1433,
"database": "Analytics",
"username": "readonly",
"password": "..."
}

Connection fields

FieldRequiredDescription
nameYesConnection name. [a-zA-Z0-9_-], max 64 chars.
db_typeYesmssql.
hostYesHostname or IP. For a named instance, append it in connection-string mode (?instance=SQLEXPRESS).
portNoDefaults to 1433.
databaseNoDefaults to master.
usernameYesDatabase user (use a read-only login). Defaults to sa.
passwordYesPassword. Omit when using Azure AD auth.
ssl / ssl_configNoTLS. With ssl_config.mode verify-ca/verify-full the connector sets Encrypt=yes;TrustServerCertificate=no; otherwise Encrypt=yes;TrustServerCertificate=yes.
ssh_tunnelNoConnect through a bastion. See Connect a Database.
connection_timeoutNoSeconds, 1–300. Mapped to pymssql login_timeout.
query_timeoutNoSeconds, 1–3600. Also drives SET LOCK_TIMEOUT to bound lock-contention waits.

Azure AD / Entra ID auth: set auth_method to azure_ad (or azure_ad_auth: true) plus azure_tenant_id, azure_client_id, and azure_client_secret (service principal). The connector uses MSAL client-credentials flow to acquire a token used in place of password, and forces encryption (Encrypt=yes;TrustServerCertificate=no). Requires the msal package.

Capabilities

CapabilitySupportedNotes
QueryYesSET TRANSACTION ISOLATION LEVEL READ COMMITTED on connect. Single reconnect attempt on a dropped connection. Default TDS version 7.4.
Schema introspectionYes (full)sys.* catalog views — tables and views, columns with precision/scale, identity flag, defaults via OBJECT_DEFINITION, comments from sys.extended_properties (MS_Description).
FK discoveryYessys.foreign_keys joined to sys.foreign_key_columns.
EXPLAINYesVia SET SHOWPLAN_ALL (estimated plan, no execution).
Cost estimationYesSET SHOWPLAN_ALL ON — parses EstimateRows and TotalSubtreeCost. USD is a rough heuristic, not a billed amount.
Schema statsYesExact row counts and table size (MB) from sys.dm_db_partition_stats; indexes and unique lead columns from sys.indexes; column auto-stats presence and row count from sys.stats / dm_db_stats_properties.

Tier 2. Schema metadata queries run sequentially (single connection; no parallel schema fetch, no connection pooling).

Dialect notes / gotchas

  • Identifiers are quoted with brackets ([col]).
  • sqlglot dialect is tsql.
  • Row limiting uses SELECT TOP n, not LIMIT n.
  • Introspection skips sys, INFORMATION_SCHEMA, and guest schemas and MS-shipped objects.
  • nvarchar/varchar/char types are reported with their length ((max) for MAX columns; nvarchar lengths are halved from byte length).

Blocked functions

There is no SQL Server–specific dangerous-function denylist. The governance layer still blocks all DDL/DML statement types, statement stacking, and SELECT ... INTO, and the universal load_extension / install_extension functions.

sql-workflow — general output-shape inference, schema exploration, and CTE-based query building.

Cloud vs local

Supported in both cloud and local (self-hosted) deployments.