> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mage.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MSSQL (Microsoft SQL Server)

## Configuration

To set up the MSSQL source, provide the following configuration parameters:

| Key        | Description                                                                                            | Sample Value      |
| ---------- | ------------------------------------------------------------------------------------------------------ | ----------------- |
| `database` | Name of the database you want to read data from.                                                       | `msdb`            |
| `host`     | Hostname of the MSSQL database, including port number at the end (e.g., `host,port`).                  | `172.20.0.2,1433` |
| `password` | Password for the MSSQL user to access the database.                                                    | `abc123...`       |
| `port`     | Port where the database is running (typically `1433`).                                                 | `1433`            |
| `schema`   | Schema of the database you want to read data from.                                                     | `public`          |
| `username` | Username that will access the database (must have read and write permissions to the specified schema). | `guest`           |

<br />

### Optional Configuration

| Key                 | Description                                                                                                                                                                                                                | Sample Value                      |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| `authentication`    | Authentication mode for connecting to MSSQL with [Azure Active Directory authentication](https://learn.microsoft.com/en-us/sql/connect/jdbc/connecting-using-azure-active-directory-authentication?view=sql-server-ver16). | `ActiveDirectoryServicePrincipal` |
| `batch_fetch_limit` | Number of rows to fetch per batch (defaults to 50,000). Adjust if your instance has more memory.                                                                                                                           | `50000`                           |
| `driver`            | ODBC [driver](https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16) for SQL Server.                                                                                | `ODBC Driver 18 for SQL Server`   |
| `connection_method` | Connection method. Set to `ssh_tunnel` to connect via SSH tunnel. Default: `direct`                                                                                                                                        | `ssh_tunnel`                      |
| `ssh_host`          | (SSH tunnel only) The host of the intermediate bastion server.                                                                                                                                                             | `123.45.67.89`                    |
| `ssh_port`          | (SSH tunnel only) The port of the intermediate bastion server. Default: `22`                                                                                                                                               | `22`                              |
| `ssh_username`      | (SSH tunnel only) The username used to connect to the bastion server.                                                                                                                                                      | `username`                        |
| `ssh_password`      | (SSH tunnel only, optional) The password used to connect to the bastion server. Required if not using `ssh_pkey`.                                                                                                          | `password`                        |
| `ssh_pkey`          | (SSH tunnel only, optional) The path to the private key used to connect to the bastion server. Required if not using `ssh_password`.                                                                                       | `/path/to/private/key`            |

<Note>
  SSH tunneling is a Mage Pro only feature.
</Note>

<br />
