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

# SQL Server

> Connect your Microsoft SQL Server database to VexiData.

<Tip>
  If you're using a managed SQL Server service, check our provider-specific guides for step-by-step instructions tailored to your platform:

  <CardGroup cols={3}>
    <Card title="Azure SQL Database" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/azure.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=cec7322fde2eb522ad6f0d2c4ed28622" href="/providers/azure-database" width="16" height="16" data-path="images/data-source-connections/azure.svg" />

    <Card title="AWS RDS" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/aws.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=ec0bac54f9403a756fcee3551b59afec" href="/providers/aws-rds" width="16" height="16" data-path="images/data-source-connections/aws.svg" />

    <Card title="Google Cloud SQL" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/google-cloud-sql.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=6402c46f70abeb5c75640caac469d4dc" href="/providers/google-cloud-sql" width="512" height="512" data-path="images/data-source-connections/google-cloud-sql.svg" />
  </CardGroup>
</Tip>

## Prerequisites

* A SQL Server database (SQL Server 2017 or later recommended) that is accessible over the network
* The database host, port, name, username, and password
* A [VexiData](https://vexidata.com) account

## Connect SQL Server to VexiData

<Steps>
  <Step title="Gather your connection details">
    You need six pieces of information to connect. If you set up SQL Server yourself, you'll already know these. If someone else manages the database, ask your database administrator.

    | Parameter    | Description                                    | Default     |
    | ------------ | ---------------------------------------------- | ----------- |
    | **Host**     | The hostname or IP address of your SQL Server  | `localhost` |
    | **Port**     | The port SQL Server is listening on            | `1433`      |
    | **Database** | The name of the database you want to query     | `master`    |
    | **Schema**   | The schema containing your tables              | `dbo`       |
    | **Username** | A SQL Server login with access to the database | `sa`        |
    | **Password** | The password for that login                    | —           |
  </Step>

  <Step title="Allow VexiData through your firewall (if applicable)">
    If your SQL Server is behind a firewall or only accepts connections from specific IPs, add VexiData's IP addresses:

    * `46.101.71.122`

    **Common places to configure this:**

    * **Azure** — Azure SQL Database firewall rules or Network Security Groups
    * **AWS** — Security Groups on the RDS instance or EC2 server
    * **Self-hosted (Windows)** — Windows Firewall with Advanced Security
    * **Self-hosted (Linux)** — Your OS firewall (e.g., `ufw`, `iptables`)

    <Info>
      If your database is only accessible from `localhost` or a private network, you'll need to either expose it to the internet or set up an SSH tunnel. VexiData requires a direct TCP connection to your database.
    </Info>
  </Step>

  <Step title="Verify SQL Server accepts remote connections">
    By default, SQL Server may not accept remote TCP connections. If your database is on a remote server, make sure it's configured correctly:

    1. Open **SQL Server Configuration Manager**
    2. Navigate to **SQL Server Network Configuration** > **Protocols for \[your instance]**
    3. Ensure **TCP/IP** is **Enabled**
    4. Right-click **TCP/IP** > **Properties** > **IP Addresses** tab, and verify the port is `1433` (or note your custom port)
    5. Restart the SQL Server service for changes to take effect

    <Info>
      If you're using a **named instance** (e.g., `MYSERVER\SQLEXPRESS`), the port may not be `1433`. Check the actual port in SQL Server Configuration Manager or use `1433` with the SQL Server Browser service running.
    </Info>

    Also verify that **SQL Server Authentication** is enabled (mixed mode):

    1. In SQL Server Management Studio (SSMS), right-click the server > **Properties**
    2. Go to **Security** and select **SQL Server and Windows Authentication mode**
    3. Restart the SQL Server service

    <Info>
      Managed database services (Azure SQL Database, AWS RDS, Google Cloud SQL) handle this automatically. You only need this step for self-hosted SQL Server.
    </Info>
  </Step>

  <Step title="Add the connection in VexiData">
    1. Go to [Data Sources](https://vexidata.com/data-sources) in VexiData
    2. Click **SQL Server** to open the connection form
    3. Fill in the details:

    | Field            | Value                                                             |
    | ---------------- | ----------------------------------------------------------------- |
    | **Display Name** | A name to identify this connection (e.g., "Production DB")        |
    | **Host**         | Your server's hostname or IP address                              |
    | **Port**         | `1433` (or your custom port)                                      |
    | **Database**     | Your database name                                                |
    | **Schema**       | `dbo` (default — change if your tables are in a different schema) |
    | **Username**     | Your SQL Server login                                             |
    | **Password**     | Your SQL Server password                                          |
  </Step>

  <Step title="Test and save">
    Click **Test & Save Connection**. VexiData will verify it can reach your database. Once connected, your schema will be analyzed automatically.
  </Step>
</Steps>

## Creating a read-only user (recommended)

For security, we recommend connecting VexiData with a dedicated read-only login instead of your admin or application user. This ensures VexiData can only read data, never modify it.

```sql theme={null}
-- Create a server login
CREATE LOGIN vexidata WITH PASSWORD = 'your-secure-password';

-- Switch to your database
USE your_database;

-- Create a database user for the login
CREATE USER vexidata FOR LOGIN vexidata;

-- Grant read-only access to the dbo schema
GRANT SELECT ON SCHEMA::dbo TO vexidata;
```

To restrict access to specific tables instead of the entire schema:

```sql theme={null}
GRANT SELECT ON dbo.orders TO vexidata;
GRANT SELECT ON dbo.customers TO vexidata;
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection timed out">
    This means VexiData can't reach your server. Check:

    * Your firewall allows inbound connections on port `1433` from VexiData's IPs
    * **TCP/IP** is enabled in SQL Server Configuration Manager
    * Your server has a public IP or hostname that resolves correctly
    * If on a cloud VM, the Security Group / firewall rules allow traffic on port `1433`
  </Accordion>

  <Accordion title="Authentication failed">
    * Verify the username and password are correct
    * SQL Server must be in **mixed authentication mode** (SQL Server and Windows Authentication) for VexiData to connect. Windows Authentication alone won't work
    * If using a dedicated login, confirm it was created with `CREATE LOGIN` and has a matching database user
  </Accordion>

  <Accordion title="Named instance: wrong port">
    If you're connecting to a named instance (e.g., `MYSERVER\SQLEXPRESS`), the port may not be `1433`. Find the actual port in SQL Server Configuration Manager under **TCP/IP Properties** > **IP Addresses** > **IPAll** > **TCP Port**. Enter this port in VexiData instead of `1433`.
  </Accordion>

  <Accordion title="No tables visible after connecting">
    * Check that your tables are in the `dbo` schema. If they're in a custom schema (e.g., `app` or `sales`), update the **Schema** field in VexiData
    * Verify your user has `SELECT` permissions: `GRANT SELECT ON SCHEMA::dbo TO your_user;`
    * Run `SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;` to confirm tables exist
  </Accordion>

  <Accordion title="SSL / TLS connection errors">
    * SQL Server 2022+ enforces TLS by default. VexiData handles this automatically
    * For older versions, verify that your server has a valid SSL certificate configured
    * If you see "certificate not trusted" errors, check that your server's certificate chain is complete
  </Accordion>
</AccordionGroup>
