> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Connect SAP HANA to Mammoth and import tables or SQL

> Connect Mammoth to SAP HANA, confirm the right port, query a schema's tables with SQL or AI, and save the result as a dataset that refreshes daily.

The SAP HANA connector imports a table, or the result of your own SQL query, from your SAP HANA database into Mammoth as a dataset. Open it from **Data Library** > **New dataset** > **Connectors** and search for **SAP HANA**. Project Admins create the connection; Project Editors can start datasets from a connection the project already has. Which connectors you can add depends on your plan.

## What you can bring in from SAP HANA

- Any table the HANA user can read, grouped by schema.
- The result of your own `SELECT` query. Only `SELECT` statements are accepted.
- A query Mammoth writes from a plain-language description, when AI query is on for your workspace.

## Before you connect SAP HANA

You need:

- An SAP HANA instance reachable from the internet.
- A HANA user with `SELECT` access to the schemas and tables you want.
- Your HANA server's **Host URL**, **Port**, **Username**, **Password** and **Database** name.
- Mammoth's IP address added to your HANA instance's allowed inbound list. See [Allow Mammoth through your firewall](https://mammoth.io/docs/learn/get-data-in/network-requirements/).

### Confirm your SAP HANA port first

The connection form pre-fills **Port** with `443`, but that's a generic default, not a HANA one. Many on-premises SAP HANA instances listen on a port in the `3<instance number>15` range instead, for example `30015` for instance `00`. Ask your HANA administrator for the correct port.

## Connect SAP HANA to Mammoth

These steps follow the shared flow in [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/).

1. Go to the **Data Library** and click **New dataset**.
2. Choose **Connectors**.
3. Search for **SAP HANA** and click its tile. The connection form opens.
4. Fill in the fields below. A callout below the fields reminds you to whitelist Mammoth's IP address in your database settings.
5. Click **Connect**. Mammoth checks the details and saves the connection. If the check fails, the error appears at the bottom of the form.

| Field | What to enter | Example |
| --- | --- | --- |
| **Host URL** | Hostname or IP address of your SAP HANA server | `hana-prod.example.com` |
| **Port** | TCP port your HANA instance listens on | Confirm with your HANA admin (see above) |
| **Username** | HANA user with `SELECT` access | `MAMMOTH_READER` |
| **Password** | Password for the HANA user | |
| **Database** | Name of the HANA database to connect to | `PROD` |
| **Display Name** | Optional label for this connection in Mammoth | `HANA Production` |

Once connected, the connector workspace opens on your tables.

## Query a SAP HANA table in the SQL view

1. In **Tables**, click a table. Mammoth opens its rows with the `SELECT *` query that read them, using double-quoted HANA identifiers, such as `SELECT * FROM "schema"."table"`.
2. To change the query, click **Edit SQL**, edit it, and click **Run** (or press Ctrl+Enter).
3. To keep only some columns, tick them in the table header.

```sql
SELECT "ORDER_ID", "CUSTOMER_ID", "AMOUNT", "ORDER_DATE"
FROM "SALES"."ORDERS"
WHERE "ORDER_DATE" >= ADD_DAYS(CURRENT_DATE, -90)
  AND "STATUS" = 'COMPLETED'
```

### Write a SAP HANA query from a description

When AI query is on for your workspace, click **Edit SQL** to see the **Describe the data you need...** box above the editor.

1. Describe what you want, for example *"all orders completed in the last 90 days"*.
2. Click **Write SQL**. Mammoth writes the query from your table structure.
3. Check the query, then click **Run**.

If a query fails, click **Fix with AI** to ask the chat to correct it. [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/) covers the full SQL view.

## Save SAP HANA data as a dataset

1. Click **Save as dataset**.
2. Enter a **Name** and choose a folder under **Save in**.
3. Under **Keep it up to date**, choose **Daily at 06:00** or **Only when I ask**.
4. Under **On each refresh**, click **Change** and choose **Replace all rows** (see below).
5. Click **Save as dataset**. When the dataset is ready, click **Open dataset**.

The **On each refresh** list shows **Replace all rows** (the default), **Add only new rows**, **Keep only the newest rows**, or **Add every row again** when the query has no column that can serve as a key column. SAP HANA refreshes don't track a key column, so choose **Replace all rows** to keep the dataset matching the source.

## Refresh SAP HANA data and choose an update method

Choosing **Daily at 06:00** creates a [Dataset Refresh](https://mammoth.io/docs/learn/automate/refresh-a-dataset/) automation for the dataset. To run it on another schedule, edit that automation. For a dataset saved with **Only when I ask**, create a Dataset Refresh automation yourself.

After you save, the dataset's **Update method** setting offers only **Replace all data** and **Add to existing data**, with no key column.

## Allow Mammoth in your SAP HANA network settings

Add Mammoth's IP address to your SAP HANA instance's allowed inbound connections. [Allow Mammoth through your firewall](https://mammoth.io/docs/learn/get-data-in/network-requirements/) gives the current address and steps.

## Troubleshoot SAP HANA connections and error codes

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Connection fails | Wrong port | Confirm the port with your HANA administrator (see [Confirm your SAP HANA port first](#confirm-your-sap-hana-port-first)) |
| Connection fails | Mammoth's IP address isn't allowed | Whitelist it in your HANA network settings |
| Connection fails | Wrong credentials | Check the username and password for the target database |
| A message that starts "HANA Error Code" | An error passed straight through from the HANA driver | Look up the code and description in SAP's HANA documentation, or ask your HANA administrator |
| No tables appear for a schema | The user lacks `SELECT` on that schema | Ask your HANA administrator to grant access to the schema and tables |
| Column ambiguity error | A join uses unqualified column names | Qualify columns with their table or alias, for example `"o"."ORDER_ID"` instead of `"ORDER_ID"` |

The message reads "HANA Error Code", then the HANA error number, a colon and HANA's description, such as an invalid object name or insufficient privileges. The number and description identify the HANA-side error.

## Related

- [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/): the shared connector workspace steps and the full SQL view.
- [Allow Mammoth through your firewall](https://mammoth.io/docs/learn/get-data-in/network-requirements/): the IP address to allow.
- [Manage saved connections](https://mammoth.io/docs/learn/get-data-in/connections/): edit, reuse or delete this connection.
- [Refresh a dataset](https://mammoth.io/docs/learn/automate/refresh-a-dataset/): change when the dataset refreshes.
- [Connector reference](https://mammoth.io/docs/learn/get-data-in/connectors/): every source Mammoth connects to.

---
Source: https://mammoth.io/docs/learn/get-data-in/connectors/sap-hana.md · Updated: 2026-11-08
