﻿---
title: Microsoft SQL Server connector
description: Use the Microsoft SQL Server connector to query tables, search rows, explore schema, and run SQL against a SQL Server database.
url: https://docs-v3-preview.elastic.dev/elastic/kibana/tree/main/reference/connectors-kibana/microsoft-sql-server-action-type
products:
  - Kibana
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Planned
---

# Microsoft SQL Server connector
Use the Microsoft SQL Server connector to query tables, search rows, and explore schema in a SQL Server database from chat conversations.
<note>
  This connector is currently available in **Agent Builder** only. Workflow support is planned for a future release.
</note>

<note>
  This connector loads its database driver upon first use. In Elastic Cloud Hosted deployments, this connector requires Kibana instances to have at least 2 GB of memory per availability zone.
</note>


## Requirements

The connector connects to SQL Server over the native Tabular Data Stream (TDS) protocol, on port 1433 by default. It works with self-managed SQL Server and with managed services that expose SQL Server, such as Amazon RDS for SQL Server. Your Kibana instance must be able to reach the server, and any firewall or security group must allow the outbound IP address of your Kibana instance. To connect to Azure SQL Database, use the [Azure SQL connector](https://docs-v3-preview.elastic.dev/elastic/kibana/tree/main/reference/connectors-kibana/azure-sql-action-type) instead.
To use the connector, you need:
- A SQL Server instance
- A SQL Server login (a user name and password) that can access the database you want to query
- The server host name, the port, the database name, and the login credentials

This connector supports SQL Server authentication only. Windows (Kerberos) authentication and Microsoft Entra ID authentication are not supported, and named instances are not supported. Connect to a named instance by using its port.
By default, the connection is encrypted. Certificate verification follows your Kibana `xpack.actions.ssl` settings and any matching `xpack.actions.customHostSettings` entry for the server. The SQL Server driver can't verify the certificate chain without also checking the hostname, so the `certificate` verification mode is treated as `full` for this connector. If the server doesn't support encryption, set **TLS** (Transport Layer Security) to **Disabled** in the connector configuration.
The connector can't be routed through an HTTP proxy. If `xpack.actions.proxyUrl` applies to the server, the connector refuses to connect instead of bypassing the proxy. Add the server name to `xpack.actions.proxyBypassHosts` to allow a direct connection.

## Get connection details

To collect the details you'll need to configure the connection:
1. Confirm the server accepts SQL Server authentication (mixed mode) and listens on a TCP port that Kibana can reach.
2. Create a SQL Server login and database user with the permissions you want Kibana to have (refer to [Database user permissions](#microsoft-sql-server-security)).
3. Note the server host name, the port, the database name, and the login credentials.


## Create connectors in Kibana

You can create connectors in **Stack Management > Connectors**.

### Connector configuration

Microsoft SQL Server connectors have the following configuration properties:
<definitions>
  <definition term="Server">
    The host name or IP address of the SQL Server instance, for example `sql.example.com`. Do not include a protocol prefix.
  </definition>
  <definition term="Port">
    The TCP port of the server (default: 1433).
  </definition>
  <definition term="Database">
    The database the connection opens in. Queries can read other databases that the login can access by using three-part names, such as `Analytics.dbo.Orders`.
  </definition>
  <definition term="TLS">
    Whether to encrypt the connection. **Required** is the default. Select **Disabled** only for servers that don't support encryption.
  </definition>
  <definition term="Username">
    The SQL Server login to authenticate as.
  </definition>
  <definition term="Password">
    The password for the login.
  </definition>
</definitions>


### Test connectors

You can test connectors as you're creating or editing the connector in Kibana.

## Microsoft SQL Server connector actions

The Microsoft SQL Server connector has the following actions:
<definitions>
  <definition term="Query">
    Run a read-only Transact-SQL (T-SQL) query against the database. Results are limited to `maxRows` rows and to the Kibana maximum response size (`xpack.actions.maxResponseContentLength`), and are marked as truncated when more rows exist.
    - **sql** (required): The `SELECT` or `WITH` query to run. Use `TOP` or `OFFSET`/`FETCH` to limit results, because `LIMIT` is not valid T-SQL. Do not include a trailing semicolon.
    - **maxRows** (optional): Maximum number of rows to return (1 to 1,000, default: 100).
  </definition>
  <definition term="List Databases">
    List the databases on the server that the login can see, with their state, compatibility level, and creation date.
  </definition>
  <definition term="List Tables">
    List the tables and views in a database, with their schema and type.
    - **database** (optional): The database to list. Defaults to the database the connector is configured for.
    - **schema** (optional): Only list objects in this schema, for example `dbo`.
  </definition>
  <definition term="Describe Table">
    Describe a table or view in the connected database, including columns, data types, nullability, defaults, primary key and unique constraints, and foreign keys.
    - **table** (required): The table or view name.
    - **schema** (optional): The schema containing the table (default: `dbo`).
  </definition>
  <definition term="Search Rows">
    Search rows in a table by matching a search term against one or more character columns, using a case-insensitive partial match.
    - **table** (required): The table to search.
    - **searchTerm** (required): The text to search for.
    - **columns** (required): The character columns to search in. Use **Describe Table** to find them.
    - **maxRows** (optional): Maximum number of rows to return (1 to 1,000, default: 100).
    - **schema** (optional): The schema containing the table (default: `dbo`).
  </definition>
</definitions>


## Database user permissions

The permissions you grant to the SQL Server login determine what the connector can do. Configure them to match your use case.

### Read-only access (recommended)

For chat conversations, use a dedicated login with read access only:
```sql
-- Run on the server
CREATE LOGIN kibana_reader WITH PASSWORD = '<password>';

-- Run in the target database
CREATE USER kibana_reader FOR LOGIN kibana_reader;
ALTER ROLE db_datareader ADD MEMBER kibana_reader;
```

To query other databases with three-part names, create a user for the login in each of those databases as well.
The **Query** action enforces read-only access in the connector by accepting only `SELECT` and `WITH` statements. It also rejects statements separated by a semicolon, and common write and session-changing forms such as `INSERT`, `UPDATE`, `DELETE`, `DROP`, `EXEC`, `SELECT ... INTO`, `BEGIN`, `SET`, and `USE`. T-SQL doesn't require a semicolon between statements, so the check can't catch every second statement. The check doesn't cover every way to change data in T-SQL, so don't rely on it alone. Use **List Tables** and **Describe Table** for schema discovery.
<warning>
  The check in the connector is not a security guarantee. Prompt injection and similar techniques can bypass it. The only reliable protection is granting the login read-only permissions. Treat the check as defense in depth, not a substitute for least-privilege credentials.
</warning>