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

# SQL Server

> SQL Server is a relational database management system, or RDBMS, developed and marketed by Microsoft.

## Overview

Hightouch lets you pull data stored in Microsoft SQL Server and push it to downstream destinations. Connecting Hightouch to Microsoft SQL Server may require some setup in both platforms. If using an Azure provisioned Microsoft SQL Server, you need to configure your firewall settings.

> [!NOTE]
>
> You may need to allowlist Hightouch's IP addresses to let our systems connect to your SQL Server instance. Reference our [networking docs](https://docs.hightouch.com/security/networking#ip-addresses) to determine which IP addresses you need to allowlist.
>
> You can also securely connect to your SQL Server instance using [AWS PrivateLink](https://docs.hightouch.com/security/aws/privatelink.md) or [GCP Private Service Connect](https://docs.hightouch.com/security/gcp/private-service-connect.md). AWS PrivateLink and GCP Private Service Connect are [Business Tier](https://hightouch.com/pricing) features.

## Azure firewall setup

*This section only applies when connecting to SQL Server instances hosted in Azure.*

By default, Azure protects your SQL Server from any external IP address from connecting to your SQL Server. Follow these steps to add Hightouch's IP addresses to the firewall:

1. Log into your [Azure Console Dashboard](https://portal.azure.com/#home).
2. Click on **SQL databases** under **Services**.
3. Select the SQL database you want to update.
4. Select **Set server firewall** .

   ![Azure Console Dashboard with settings](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/sources/source-sqlserver-firewall.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=a15e17c4783711c354be464240a9bf08)
5. Under **Public network access**, select **Selected networks**.

   ![Azure Console Dashboard with settings](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/sources/source-sqlserver-firewall-setup-1.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=b21bf4858d1072bea78c5ac4558624f8)
6. Scroll to **Firewall rules** and click **Add a firewall rule**.

   ![Azure Console Dashboard with settings](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/sources/source-sqlserver-firewall-setup-2.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=f2a972f825c9aaaa0f62d2029c3084ad)
7. Allowlist the [Hightouch IP addresses](https://docs.hightouch.com/security/networking#ip-addresses) for your region.
8. Click the **Save** button on the bottom left.

## Connection configuration

In Hightouch, go to the [**Sources** overview page](https://app.hightouch.com/sources?from=docs) and click the **Add source** button. Select **Microsoft SQL Server** and follow the steps below.

### Choose authentication method

When creating a SQL Server source, you can either enter the Host, Port, Database, User, and Password by selecting **Password** or you can provide the full URI **Connection string**.

#### Connection string

Enter your connection string in this format: `Server=server;Database=database;User Id=username;Password=password;Encrypt=boolean`.

Once you've entered your connection string and clicked **Continue**, you can skip to the [Test your Connection](#test-your-connection) section of this doc.

### Choose connection type

Hightouch can connect directly to true over the public internet or via an SSH tunnel. Since data is encrypted in transit via TLS, a direct connection is suitable for most use cases. You may need to set up a tunnel if your true instance is on a private network or virtual private cloud (VPC).

![Direct connection vs. SSH tunnel](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/get-started/connection-types-comparison.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=2300535707894b1f08608939cac812b2)

Hightouch supports both standard and reverse SSH tunnels. To learn more about SSH tunneling, refer to Hightouch's [tunneling documentation](https://docs.hightouch.com/security/ssh-tunneling.md).

### Configure your source

Enter the following required fields into Hightouch:

* **Host**: The hostname or IP address of your Microsoft SQL Server. If using the hostname, make sure to only insert the hostname and not the full URL (remove the leading `http://` and the final `/`).
* **Port**: The port number of your Microsoft SQL Server. The default is 1433, but yours may be different.
* **Database**: The name of the database in your Microsoft SQL Server.
* **User**: This can be your personal Microsoft SQL Server login or a dedicated user for Hightouch.
* (Optional) **Password**: The password for the user specified above.

Optionally you can enter a **Request timeout duration** and whether to **Trust server certification**.

## Test your connection

When setting up Microsoft SQL Server as a source for the first time, Hightouch validates your credentials and access to your database. Once the test passes, click **Continue** to finish setup.

If you see the following error message, you need to [update your firewall settings](#azure-firewall-setup) in your Azure Console.

```json theme={null}
Cannot open server 'hightouch-test' request by login.
Client with IP address '54.196.30.169' is not allowed to access the server.
To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule
on the master database to create a firewall rule for this IP address or address range.
It may up take up to five minutes for this change to take effect.
```

## Create models

Once your source configuration has passed the necessary validation, you've completed setting up Microsoft SQL Server as a source. Next, you can set up [models](https://docs.hightouch.com/getting-started/concepts.md#models) to define which data you want to pull from Microsoft SQL Server.

The Microsoft SQL Server source supports these modeling methods:

* writing a query in [the SQL editor](https://docs.hightouch.com/models/sql-editor.md)
* using the visual [table selector](https://docs.hightouch.com/models/table-selector.md)
* leveraging existing [dbt models](https://docs.hightouch.com/extensions/dbt-models.md)

## Tips and troubleshooting

Most issues with the Microsoft SQL Server source can be resolved by verifying the firewall settings according to the setup instructions above.

If you see an error message similar to the following

```json theme={null}
Login failed for user '<username>'
```

or

```json theme={null}
login failed for user '<domain>\<username>'
```

verify that the username and password work locally. You may also need to adjust your Microsoft SQL Service authentication mode. See [Microsoft's documentation](https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-18456-database-engine-error?view=sql-server-ver16#login-failed-for-user-username-or-login-failed-for-user-domainusername) for more information about login errors and authentication modes.
