---
title: "SQL Server"
description: "Connect Metabase to SQL Server or Azure SQL, including which versions are supported and every connection setting."
url: "https://www.metabase.com/docs/latest/databases/connections/sql-server"
version: "65"
---

> For the complete documentation index, see [llms.txt](https://www.metabase.com/docs/llms.txt).

# SQL Server

To add a database connection, click the **grid** icon in the top right, and navigate to **Admin** > **Databases** > **Add a database**.

## Supported versions

Metabase supports the oldest supported version of SQL Server through the latest stable version. See [SQL Server end of support options](https://learn.microsoft.com/en-us/sql/sql-server/end-of-support/sql-server-end-of-support-overview).

## Settings

You can edit these settings at any time. Just remember to save your changes.

### Connection string

Paste a connection string here to pre-fill the remaining fields below.

### Display name

The display name for the database in the Metabase interface.

### Host

Your database's IP address, or its domain name (e.g., esc.mydatabase.com).

### Port

The database port. E.g., 1433. To use Dynamic Ports, leave this field empty.

### Database name

The name of the database you're connecting to.

### Database instance name

If you're running multiple databases on the same host, you can include the instance name here.

### Username

The username Metabase uses to connect to your database. Create a dedicated database user for Metabase with read-only access to the schemas and tables you want to analyze. For write operations like uploads, actions, or transforms, use a separate [writable connection](https://www.metabase.com/docs/latest/databases/writable-connection.md). For instructions, see [Database users, roles, and privileges](https://www.metabase.com/docs/latest/databases/users-roles-privileges.md). You can set up multiple connections to the same database using different user accounts, each with different sets of privileges.

### Password

The password for the username that you use to connect to the database.

### Use a secure connection (SSL)

Metabase automatically tries to connect to databases with SSL first, then without if that doesn't work. If it's possible to connect to your database with an SSL connection, Metabase will make that the default setting for your database. If you prefer to connect without this layer of security, you can always change this setting later, but we recommend keeping SSL turned on to keep your data secure.

### Use an SSH tunnel

See our [guide to SSH tunneling](https://www.metabase.com/docs/latest/databases/ssh-tunnel.md).

### Additional JDBC connection string options

You can append options to the connection string that Metabase uses to connect to your database.

### Re-run queries for simple explorations

Turn this option **OFF** if people want to click **Run** (the play button) before applying any [Summarize](https://www.metabase.com/docs/latest/questions/query-builder/summarizing-and-grouping.md) or filter selections.

By default, Metabase will execute a query as soon as you choose a grouping option from the **Summarize** menu or a filter condition from the [drill-through menu](https://www.metabase.com/docs/latest/questions/visualizations/drill-through.md). If your database is slow, you may want to disable re-running to avoid loading data on each click.

### Choose when syncs and scans happen

See [syncs and scans](https://www.metabase.com/docs/latest/databases/sync-scan.md#choose-when-syncs-and-scans-happen).

#### Database syncing

If you've selected **Choose when syncs and scans happen** > **ON**, you'll be able to set:

- The frequency of the [sync](https://www.metabase.com/docs/latest/databases/sync-scan.md#how-database-syncs-work): hourly (default) or daily.
- The time to run the sync, in the timezone of the server where your Metabase app is running.

### Scanning for filter values

Metabase can scan the values present in each field in this database to enable checkbox filters in dashboards and questions. This can be a resource-intensive process, particularly if you have a large database.

If you've selected **Choose when syncs and scans happen** > **ON**, you'll see the following options under **Scanning for filter values**:

- **Regularly, on a schedule** allows you to run [scan queries](https://www.metabase.com/docs/latest/databases/sync-scan.md#how-database-scans-work) at a frequency that matches the rate of change to your database. The time is set in the timezone of the server where your Metabase app is running. This is the best option for a small database, or tables with distinct values that get updated often.
- **Only when adding a new filter widget** is a great option if you want scan queries to run on demand. Turning this option **ON** means that Metabase will only scan and cache the values of the field(s) that are used when a new filter is added to a dashboard or SQL question.
- **Never, I'll do this manually if I need to** is an option for databases that are either prohibitively large, or which rarely have new values added. Use the [Re-scan field values](https://www.metabase.com/docs/latest/databases/sync-scan.md#manually-scanning-column-values) button to run a manual scan and bring your filter values up to date.

### Periodically refingerprint tables

> Periodic refingerprinting will increase the load on your database.

Turn this option **ON** to scan a sample of values every time Metabase runs a [sync](https://www.metabase.com/docs/latest/databases/sync-scan.md#how-database-syncs-work).

A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup.

## Connecting to Azure SQL

To connect to Azure SQL, set the port to 1433. Under **Authentication method**, pick how the server will identify Metabase:

- **SQL Server login**: a traditional username and password. Only works when SQL authentication is enabled on the server.
- **Azure AD - Service principal**: Metabase authenticates as an [Entra ID app registration](https://learn.microsoft.com/en-us/entra/identity-platform/app-objects-and-service-principals). Fill in the **Client ID** and **Client secret** from the app registration, and grant that service principal `CONNECT` on the target database.
- **Azure AD - Service principal (certificate)**: Same as service principal, but authenticates with the app registration's certificate.  Upload the **Client certificate**.
  - If the certificate needs a password, provide the password in **Certificate password**.
  - If the private key is stored in a separate file, provide the key in **Client key**. If the key is encrypted, fill in its password in **Client key password**.
- **Azure AD - Managed identity**: This mode only works when Metabase runs inside Azure. Metabase authenticates using the [managed identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview) assigned to the compute that your Metabase is running on (App Service, Container Apps, VM, AKS). To use the default identity, leave **Managed identity client ID** blank. You can also fill in a specific user-assigned managed identity. 

## Writable connection

Set up an additional connection used for write operations. See [Writable connections](https://www.metabase.com/docs/latest/databases/writable-connection.md).

## Database routing

With database routing, an admin can build a question once using one database, and the question will run its query against a different database with the same schema depending on who is viewing the question.

See [Database routing](https://www.metabase.com/docs/latest/permissions/database-routing.md).

## Danger zone

See [Danger zone](https://www.metabase.com/docs/latest/databases/danger-zone.md).

## Further reading

- [Microsoft JDBC Driver for SQL Server support matrix](https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix)
- [Managing databases](https://www.metabase.com/docs/latest/databases/connecting.md)
- [Metadata editing](https://www.metabase.com/docs/latest/data-modeling/metadata/metadata-editing.md)
- [Models](https://www.metabase.com/docs/latest/data-modeling/models/models.md)
- [Setting data access permissions](https://www.metabase.com/docs/latest/permissions/data.md)
