> For the complete documentation index, see [llms.txt](https://docs.telm.ai/telmai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telm.ai/telmai/connect-to-data/data-connections/sql-server.md).

# MS SQL Server

Connect Telmai to Microsoft SQL Server, including Azure SQL Database.

Telmai reads tables from Microsoft SQL Server wherever it runs: on premises, on a virtual machine, or as a managed service such as Azure SQL Database, Azure SQL Managed Instance or Amazon RDS. For a Microsoft Fabric warehouse or lakehouse, use [Microsoft Fabric SQL](https://docs.telm.ai/telmai/connect-to-data/data-connections/microsoft-fabric.md) instead.

## Before you connect

1. Create a login and a database user for Telmai, and grant it read access on the database, for example the `db_datareader` role. To authenticate without a password on Azure, set up a managed identity instead; see [Azure Managed Identity Authentication](https://docs.telm.ai/telmai/connect-to-data/data-connections/sql-server-managed-identity.md).
2. Table freshness reads `sys.dm_db_index_usage_stats`, which needs `VIEW SERVER STATE` (`VIEW SERVER PERFORMANCE STATE` on SQL Server 2022 and later). On Azure SQL Database, grant `VIEW DATABASE STATE` or the `##MS_ServerStateReader##` role instead. On the Basic, S0 and S1 tiers and in elastic pools, only the server admin can read it.

If the server is privately hosted or behind a firewall, allowlist the addresses in [IP Allowlist](https://docs.telm.ai/telmai/api-reference/telmai-ip-list.md).

## Connection fields

On the **Connections** page, click **Add connection** and choose **MS SQL Server**. See [Add a connection](https://docs.telm.ai/telmai/connect-to-data.md#add-a-connection) for the full flow.

| Field                        | Description                                                                                                                            |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| **Schema**                   | The schema to connect to, for example `dbo`.                                                                                           |
| **Server**                   | The server host name, for example `your-server.database.windows.net`. In the Azure portal, it's on the SQL server's **Overview** page. |
| **Port**                     | The server port. Default: `1433`.                                                                                                      |
| **Database**                 | The database name.                                                                                                                     |
| **Encrypt**                  | Whether to encrypt the connection. Default: `true`.                                                                                    |
| **Trust Server Certificate** | Whether to accept the server's certificate without validating it. Default: `false`.                                                    |
| **Authentication Scheme**    | How Telmai signs in. See [Authentication schemes](#authentication-schemes).                                                            |
| **Managed Identity**         | The registered identity to authenticate as. Appears only for **Managed Identity (connection)**.                                        |
| **User**                     | The SQL Server login, or the Microsoft Entra user name.                                                                                |
| **Password**                 | The password for that user.                                                                                                            |

**User** and **Password** appear only for **SQL Server Login** and **Microsoft Entra Password**.

### Authentication schemes

| Scheme                        | What it uses                                                                                                                                                                                                                                                      |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SQL Server Login              | A SQL Server user name and password, stored on the connection.                                                                                                                                                                                                    |
| Microsoft Entra Password      | A Microsoft Entra user name and password, stored on the connection.                                                                                                                                                                                               |
| Managed Identity (connection) | A managed identity registered by a Telmai administrator. Nothing secret is stored. Available on Azure deployments only. See [Azure Managed Identity Authentication](https://docs.telm.ai/telmai/connect-to-data/data-connections/sql-server-managed-identity.md). |

## Asset fields

Click **Add assets** on the connection. See [Add assets](https://docs.telm.ai/telmai/connect-to-data.md#list-of-connectors-enabled-by-default).

| Field               | Description                                                                                                                                                                            |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Connection mode** | **Existing table** to pick tables or views, or **Custom query** to define the asset with SQL. See [Connection Modes](https://docs.telm.ai/telmai/connect-to-data/connection-modes.md). |

## Limitations

* The JSON data type isn't supported by default. Contact Telmai support to turn it on.
