SQL Server Adapter

Generate T-SQL for Microsoft SQL Server and Azure SQL from your model.

What the adapter emits

  • Identifiers in [brackets]; bare column names in expressions are lowercased.
  • Grain truncation as DATETRUNC(month, x) (SQL Server 2022 and Azure SQL); parts with YEAR(x), DATEPART(QUARTER, x), DATEPART(WEEKDAY, x).
  • CTEs for the per-fact subqueries and a FULL OUTER JOIN when a query blends measures from two facts.
  • No array functions: expression.array: true is not supported on this adapter.

Configuration

sqlserver_db:
  adapter: sqlserver
  name: SQL Server Database
  tier: warm
  host: server.database.windows.net
  port: 1433
  database: analytics
  username: analyst
  # password: never here; zsql deploy strips it if present

Azure SQL uses the same adapter; the difference is in how your application connects, not in the SQL.

Connection fields

0sql never connects to SQL Server. The fields above are carried as metadata for your own application, which runs the SQL it gets back. 0sql never uses them. If a password does land in datasources.yml, zsql deploy strips it before building the archive.

Notes

  • Expressions are T-SQL. count_big, iif(), string_agg and try_cast are fine in expression.sql.
  • Schema-qualified tables go in physical_name (dbo.store_sales).

Next Steps