Skip to content

Limits

Queries

Limit Value
Longest execute_query text (network buffer size − 8) / 2 characters. 380 with a 768-byte buffer
... on a TLS connection 11 characters fewer (a 22-byte header)
Longest execute_rpc query text 4000 characters, and the request must fit into the network buffer
Longest execute_rpc parameter declarations 4000 characters. tdslite declares each parameter as @p0 INT, @p1 VARCHAR(30) and so on, joined with commas: about 400 INT parameters
Query that doesn't fit Not sent; the result reports request_too_large

Queries are sent as UTF-16, so every character takes two bytes. 8 bytes of the buffer are kept for the packet header.

Result sets

Limit Value
Rows per result set No limit: rows go to the callback one at a time
Size of one row Must fit into the network buffer
Row, column list or message that doesn't fit The query ends with response_too_large and network_error; the connection is closed; reconnect

For example, a row with a single varchar of 760 characters can be read with a 768-byte buffer, one of 800 characters can't. A 500-row result set reads through a 256-byte buffer.

Connection

Limit Value
packet_size 512 – 32767. The login is sent in packets of at most 4096 bytes
conn_retry_count, conn_retry_delay_ms At most 65535
Host name (BSD sockets, ESP-IDF backends) 255 characters

Platform

C++ standard C++11 or newer. The unit tests are also built as C++14, C++17 and C++20
SQL Server 2017, 2019, 2022 (plaintext) and 2025 (TLS) are tested in CI on every pull request
TLS (strict mode) SQL Server 2025, SQL Server 2022 on Windows, Azure SQL. Not SQL Server 2022 on Linux
Authentication SQL Server authentication. Windows (integrated) authentication isn't supported
Protocol tdslite logs in as a TDS 7.1 client, on TLS (TDS 8.0 strict) connections too
ESP-IDF 5.0 or newer

Memory on an Arduino Uno

Measured on an ATmega328P (2 kB of SRAM):

Sketch Network buffer Packet size RAM Flash
A minimal query sketch with the Ethernet library (2.0.2) 768 bytes 512 1236 bytes used by global variables, of 2048 23296 bytes
The simulation test firmware: queries, parameterized queries and multi-packet result sets on a simulated Uno 640 bytes 512 501 bytes free while running 25848 bytes

ESP-IDF TLS

Measured on an ESP32 (in QEMU) with ESP-IDF 5.5's default mbedTLS settings:

Heap while connected About 30 kB, all of it mbedTLS's. Freed on disconnect
Stack About 500 bytes more than the plaintext backend

ESPHome component

The sql_server component has a 4096-byte network buffer. Measured on an ESP32 (ESP-IDF and Arduino frameworks) over Wi-Fi, against SQL Server 2025:

Limit Value
Query text without parameters 2044 characters; 2033 over TLS
A query with parameters The query and all parameters must fit in 4 KB. Text is UTF-16: a 1900-character parameter fits, a 4000-character one doesn't
One row of a result Must fit in 4 KB. A VARCHAR(4000) value fits; a full NVARCHAR(4000) value (8000 bytes) doesn't, whatever max_text_size is
Rows of a result No limit: 20,000 rows read in 0.6 s (only the first is kept)
Requests a second About 75 one after another; about 95 with the queue kept full. The same with TLS
Requests waiting queue_size (16 by default, up to 256), plus the one being sent
RAM, each sql_server About 14 kB: the worker thread's 8 kB stack, the network buffer and the queue
TLS About 28 kB more heap while connected, and about 68 kB of flash

A request that doesn't fit isn't sent: on_error says too large for the 4 KB network buffer. A row that doesn't fit ends the request with Response too large, and the component reconnects.

An 8-minute soak test (10 inserts a second, three sensors polling every second, the session killed every 45 s) stored every insert that succeeded exactly once, and the free heap was the same at the end as after the first minute.