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

# Connecting Microsoft SQL Server to Omni

> Learn how to retrieve connection details and connect your Microsoft SQL Server database to Omni.

export const BaseAccess = () => {
  return <span>
      <ParamField path="Base Access" required>
        Select the <a href="/administration/users/permissions">minimum level of access</a> users should have to models in the connection.
      </ParamField>
    </span>;
};

export const QueryTimeout = ({defaultValue}) => {
  return <span>
      <ParamField path="Query Timeout" default={defaultValue}>
        Maximum time in seconds before a query times out.
      </ParamField>
    </span>;
};

export const AutoGenerateRelationships = () => {
  return <span>
      <ParamField path="Auto-generate relationships" default="enabled">
        When enabled, Omni will automatically infer relationships between tables based on column name matching during schema refreshes. Defaults to enabled.
      </ParamField>
    </span>;
};

export const AllowUserSpecificTimezones = () => {
  return <span>
      <ParamField path="Allow User-Specific Timezones">
        When enabled, users can override the connection timezone with their own when querying.
      </ParamField>
    </span>;
};

export const QueryTimezone = () => {
  return <span>
      <ParamField path="Query Timezone" required>
        The timezone to use for Omni queries. If a timezone is specified, data will be converted from the <strong>Database Timezone</strong> to the selected timezone.
      </ParamField>
    </span>;
};

export const DatabaseTimezone = () => {
  return <span>
      <ParamField path="Database Timezone" required>
        The timezone used by the database.
      </ParamField>
    </span>;
};

export const TrustServerCertificate = () => {
  return <span>
      <ParamField path="Trust Server Certificate">
        Whether to trust the server's SSL/TLS certificate without validation.
      </ParamField>
    </span>;
};

export const Password = () => {
  return <span>
      <ParamField path="Password" required>
        The password for database authentication.
      </ParamField>
    </span>;
};

export const Username = () => {
  return <span>
      <ParamField path="Username" required>
        The username for database authentication.
      </ParamField>
    </span>;
};

export const Default = ({term = "Schema", required = true, defaultValue}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Default ${term}`} required={required} default={defaultValue}>
        The default {lower} for the connection.
      </ParamField>
    </span>;
};

export const TableUploads = ({label = "Schema for Table Uploads", term = "schema"}) => {
  return <span>
      <ParamField path={label}>
        The name of the {term} to use for table (CSV) uploads. If left blank, you can upload tables but they won't be pushed to the database or be available for use in joins.
      </ParamField>
    </span>;
};

export const Offloaded = ({term = "Schemas"}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Offloaded ${term}`}>
        A comma-separated list of {lower} to include in the connection, which will only load on demand. This setting is good for large {lower} or dbt dev {lower}.
      </ParamField>
    </span>;
};

export const Include = ({term = "Schemas"}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Include ${term}`}>
        A comma-separated list of {lower} to include in the connection.
      </ParamField>
    </span>;
};

export const Database = () => {
  return <span>
      <ParamField path="Database" required>
        The database to connect to.
      </ParamField>
    </span>;
};

export const Port = ({defaultValue}) => {
  return <span>
      <ParamField path="Port" required default={defaultValue}>
        The port number for the database connection.
      </ParamField>
    </span>;
};

export const Host = () => {
  return <span>
      <ParamField path="Host" required>
        The address of the database server.
      </ParamField>
    </span>;
};

export const DisplayName = () => {
  return <span>
      <ParamField path="Display Name" required>
        A user-friendly name for the connection, which will be used throughout Omni.
      </ParamField>
    </span>;
};

## Requirements

To follow the steps in this guide, you'll need:

* **Organization Admin permissions in Omni**
* **Microsoft Azure Portal Admin permissions**, which are required to allowlist Omni's IP addresses

## Setup

<Steps>
  <Step title="Retrieve connection details" titleSize="h3">
    1. Navigate to your [Microsoft Azure Portal](https://portal.azure.com/#home).

    2. In the portal, navigate to the database you want to connect to Omni.

    3. On the database's details page, locate the **Connection strings** field:

           <img src="https://mintcdn.com/omni-e7402367/XZwrvFN-b2pRXANo/connect-data/images/ms-azure-portal.png?fit=max&auto=format&n=XZwrvFN-b2pRXANo&q=85&s=3fcac2b9e21800d612fcecc1cb6d1fa1" alt="Connection strings link" width="3456" height="1710" data-path="connect-data/images/ms-azure-portal.png" />

    4. Click the **Show database connection strings** link.

    5. On the page that displays, click the **JDBC** tab:

           <img src="https://mintcdn.com/omni-e7402367/XZwrvFN-b2pRXANo/connect-data/images/ms-azure-strings.png?fit=max&auto=format&n=XZwrvFN-b2pRXANo&q=85&s=06aa2f4d20ebb93eddd78cf828e5308d" alt="Connection string" width="3444" height="1482" data-path="connect-data/images/ms-azure-strings.png" />

    6. You should see something like the following, which will contain all the information you need:

       ```yaml theme={null}
       jdbc:sqlserver://omni-test-admin.database.windows.net:1433;
       database=e-commerce;
       user=omni-test-admin@omni-test-admin;
       password={your_password_here};
       encrypt=true;
       trustServerCertificate=false;
       hostNameInCertificate=*.database.windows.net;
       loginTimeout=30;
       ```
  </Step>

  <Step title="Set up a table upload schema" titleSize="h3">
    <Callout icon="hand-point-up" color="#ff4179">
      **This step is optional.** However, we recommend completing it as part of the initial set up or you won't be able to use uploaded files like CSVs in joins.
    </Callout>

    In this step, you'll create a dedicated schema to use for [table uploads](/analyze-explore/data-input-csvs). This schema can't be used for other modeled tables.

    1. Create the schema in Microsoft SQL Server. This can be in its own database or the same database as other schemas to be used in modeling.
    2. Run the following commands to grant the Omni user the required privileges:

       ```sql title="Grant Omni user permissions to upload schema" theme={null}
       GRANT CREATE TABLE TO omni;
       GRANT ALTER, INSERT, SELECT, UPDATE ON SCHEMA::upload_schema_name TO omni;
       ```
  </Step>

  <Step title="Allowlist Omni's IP addresses" titleSize="h3">
    If access to the SQL Server database is limited by IP address, you'll need to add Omni's IPs to the allowlist before you create the database connection.

    Omni's IP addresses can be found on an individual connection's page, accessed by navigating to **Settings > Connections** and clicking a connection.

    1. Navigate to your [Microsoft Azure Portal](https://portal.azure.com/#home).

    2. In the left navigation, click the **Networking** option under **Security**.

    3. In the **Firewall rules** section, click **Add a firewall rule**:

           <img src="https://mintcdn.com/omni-e7402367/XZwrvFN-b2pRXANo/connect-data/images/ms-portal-firewall-add.png?fit=max&auto=format&n=XZwrvFN-b2pRXANo&q=85&s=51d7a208c760c026c77d0418f7da3d65" alt="Add firewall rule" width="3452" height="1914" data-path="connect-data/images/ms-portal-firewall-add.png" />

    4. Create a rule for each of Omni's IP addresses:

           <img src="https://mintcdn.com/omni-e7402367/XZwrvFN-b2pRXANo/connect-data/images/ms-portal-firewall-input.png?fit=max&auto=format&n=XZwrvFN-b2pRXANo&q=85&s=5dba9c3ec4d2f8f80caed72ec5d6e334" alt="Firewall rule input" width="1798" height="720" data-path="connect-data/images/ms-portal-firewall-input.png" />
  </Step>

  <Step title="Create the connection in Omni" titleSize="h3">
    1. In Omni, click **Settings > Connections**.

    2. Click the **Microsoft SQL Server** option.

    3. On the connection setup page, fill in the connection details:

           <DisplayName />

           <Host />

           <Port defaultValue="1433" />

           <Database />

           <Include />

           <Offloaded />

           <TableUploads />

           <Default defaultValue="dbo" />

           <Username />

           <Password />

           <TrustServerCertificate />

           <DatabaseTimezone />

           <QueryTimezone />

           <AllowUserSpecificTimezones />

           <AutoGenerateRelationships />

           <QueryTimeout defaultValue="900" />

           <BaseAccess />

    4. When finished, click **Create connection**.
  </Step>
</Steps>

## What's next?

Now that your database is set up, you can:

* Use the Omni Agent's [quickstart skill](/modeling/topics/quickstart) to create your first topic from business questions
* Configure user permissions, [schema refreshes](/modeling/develop/schema-refreshes), [environments](/connect-data/dynamic-environments) and [timezone settings](/connect-data/timezones)
* Learn how Omni [generates the model](/modeling/develop/model-generation) associated with the connection
