Skip to content

ConnectionPromises.Function.execSqlIterator

Christian d'Heureuse edited this page Oct 15, 2026 · 1 revision

tedious-plus / ConnectionPromises / execSqlIterator

Function: execSqlIterator()

function execSqlIterator(
   connection, 
   request, 
   options?
): AsyncRowIterator;

Defined in: ConnectionPromises.ts:278

Executes an SQL query and returns an AsyncRowIterator to process the result set.

This is a promisified version of Connection.execSql(). This variant returns an AsyncIterator that allows processing the rows as soon as they arrive from the database server.

Usage:

const request = new Tedious.Request("select name from sys.databases", () => {});
const iterator = ConnectionPromises.execSqlIterator(connection, request);
for await (const row of iterator) {
   console.log(row);
}

Parameters

connection

Connection

An open Tedious connection.

request

Request

The Tedious request to be executed.

options?

Partial<AsyncRowIteratorOptions>

Optional settings for the iterator.

Returns

AsyncRowIterator

An iterator for the result rows. When the request fails, the error is thrown within the for await loop.

Clone this wiki locally