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

# Microsoft SQL Server Integration for AI Agents & Workflows

> Execute queries and manage data in Microsoft SQL Server databases

{/* Self-hosted logo — build-time vendored from modulex.json / Iconify (see scripts/lib/logo.js). */}

<img src="https://mintcdn.com/modulexaillc/df8MOr-hXotYLTh5/logos/microsoft-sql-server.svg?fit=max&auto=format&n=df8MOr-hXotYLTh5&q=85&s=df7d81ce3e366aa805861dbc7b77c45a" alt="Microsoft SQL Server logo" width="72" height="72" data-path="logos/microsoft-sql-server.svg" />

## Overview

Add **Microsoft SQL Server** to any ModuleX agent or workflow. Execute queries and manage data in Microsoft SQL Server databases via direct TCP connections using `pymssql`.

<Info>
  **Categories**: Databases · Data Infrastructure · **Auth**: SQL Server Connection · **Actions**: 4
</Info>

## Authentication

### SQL Server Connection

Connect using SQL Server host, port, database, username, and password

#### Required Credentials

| Field                    | Description                                                                     | Required | Format                          |
| ------------------------ | ------------------------------------------------------------------------------- | -------- | ------------------------------- |
| Host                     | SQL Server hostname or IP address                                               | Yes      | `myserver.database.windows.net` |
| Port                     | SQL Server port number                                                          | Yes      | `1433`                          |
| Username                 | SQL Server login username                                                       | Yes      | `-`                             |
| Password                 | SQL Server login password                                                       | Yes      | `-`                             |
| Database                 | Name of the database to connect to                                              | Yes      | `-`                             |
| Encrypt                  | Whether to encrypt the connection (true/false). Use true for Azure SQL.         | No       | `true`                          |
| Trust Server Certificate | Whether to trust self-signed certificates (true/false). Use true for local dev. | No       | `false`                         |

## Available Actions

<AccordionGroup>
  <Accordion title="execute_raw_query — Execute a raw SQL query against the database and return results">
    ### Parameters

    <ResponseField name="query" type="string" required>
      The SQL query to execute
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "recordset": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "title": "Recordset",
          "type": "array"
        },
        "rows_affected": {
          "items": {
            "type": "integer"
          },
          "title": "Rows Affected",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "ExecuteRawQueryOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="execute_query — Execute a parameterized SQL query with named inputs">
    ### Parameters

    <ResponseField name="query" type="string" required>
      The SQL query to execute, using @name placeholders for parameters
    </ResponseField>

    <ResponseField name="inputs" type="object">
      Key-value mapping of parameter names to values for the query placeholders
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "recordset": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "title": "Recordset",
          "type": "array"
        },
        "rows_affected": {
          "items": {
            "type": "integer"
          },
          "title": "Rows Affected",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "ExecuteQueryOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="insert_row — Insert a new row into a specified table">
    ### Parameters

    <ResponseField name="table" type="string" required>
      Name of the table to insert into
    </ResponseField>

    <ResponseField name="data" type="object" required>
      JSON object mapping column names to values for the new row
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "rows_affected": {
          "items": {
            "type": "integer"
          },
          "title": "Rows Affected",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "InsertRowOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="list_table_options — List all available base tables in the database">
    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "tables": {
          "items": {
            "type": "string"
          },
          "title": "Tables",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "ListTableOptionsOutput",
      "type": "object"
    }
    ```
  </Accordion>
</AccordionGroup>

## Limits & Quotas

* No API rate limits apply; performance depends on the SQL Server instance capacity and network latency.
* Connection timeout defaults to pymssql's default (dependent on server responsiveness).
* Query execution is wrapped in `asyncio.to_thread` so it does not block the event loop.
* Error model: connection failures, query syntax errors, and timeouts are caught and returned as `success=False` + `error` rather than raising.

## Related integrations

<CardGroup cols={3}>
  <Card title="MySQL" href="/integrations/tools/mysql" />

  <Card title="PostgreSQL" href="/integrations/tools/postgresql" />

  <Card title="Snowflake" href="/integrations/tools/snowflake" />
</CardGroup>

## Links

* [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server)
