# Microsoft SQL Server
source: https://docs.chalk.ai/docs/mssql

## Integrate with Microsoft SQL Server data sources.

Chalk supports Microsoft SQL Server
and Azure SQL Database
as a SQL source.
You can configure the Microsoft SQL Server-specific
options using the MSSQLSource init args,
or configure the source through your dashboard at Integrations > Add a data source, and
reference the source in your code.

### Prerequisites

For local development, you'll need to install ODBC drivers:

- macOS: brew install unixodbc
- Linux (Ubuntu/Debian): sudo apt-get install unixodbc unixodbc-dev
- Linux (RHEL/CentOS): sudo yum install unixODBC unixODBC-devel

Then install the Python package: pip install 'chalkpy[mssql]'

Production deployments on Chalk handle ODBC drivers automatically.

### Adding Microsoft SQL Server

On the dashboard at Integrations > Add a data source, you can plug in the configuration for your
Microsoft SQL Server database, such as hostname, port, and database name.

### Authentication Methods

Chalk supports three authentication methods:

SQL Authentication - Traditional username and password authentication

Azure AD Managed Identity - When running in Azure (such as in AKS or Azure VMs), Chalk can automatically authenticate using Managed Identity. Simply omit authentication credentials when configuring your source.

Azure AD Service Principal - For authentication using an Azure AD application, provide client_id, client_secret, and tenant_id.

### Integrations Setup

After configuring your Microsoft SQL Server integration in the dashboard, define your data sources in Python:

```
from chalk.sql import MSSQLSource

risk_source = MSSQLSource(name="risk")
marketing_source = MSSQLSource(name="marketing")
```

Then reference them in SQL file resolvers using the name parameter. For example, to query from the risk source:

```
-- type: online
-- resolves: User
-- source: risk
SELECT id, credit_score FROM users
```

And to query from the marketing source:

```
-- type: online
-- resolves: User
-- source: marketing
SELECT id, email, campaign_status FROM users
```







