Skip to content

ConnectionPromises.Function.execSql

Christian d'Heureuse edited this page Oct 28, 2026 · 2 revisions

tedious-plus / ConnectionPromises / execSql

Function: execSql()

Call Signature

function execSql(connection, request): Promise<RequestResult<"ObjectRow">>;

Defined in: ConnectionPromises.ts:236

Executes an SQL query and returns the result.

This is a promisified version of Connection.execSql(). The rows of the result set are buffered in an array and returned on completion. The optional parameter rowType specifies the format of the rows (default: "ObjectRow").

Usage:

const request = new Tedious.Request("select name from sys.databases", () => {});
const result = await ConnectionPromises.execSql(connection, request);
console.log(result.rows);

Parameters

connection

Connection

An open Tedious connection.

request

Request

The Tedious request to be executed.

Returns

Promise<RequestResult<"ObjectRow">>

A promise for the result of the request. The promise is rejected when the request fails.

Call Signature

function execSql<RT>(
   connection, 
   request, 
   rowType
): Promise<RequestResult<RT>>;

Defined in: ConnectionPromises.ts:237

Executes an SQL query and returns the result.

This is a promisified version of Connection.execSql(). The rows of the result set are buffered in an array and returned on completion. The optional parameter rowType specifies the format of the rows (default: "ObjectRow").

Usage:

const request = new Tedious.Request("select name from sys.databases", () => {});
const result = await ConnectionPromises.execSql(connection, request);
console.log(result.rows);

Type Parameters

RT

RT extends RowType

Parameters

connection

Connection

An open Tedious connection.

request

Request

The Tedious request to be executed.

rowType

RT

Returns

Promise<RequestResult<RT>>

A promise for the result of the request. The promise is rejected when the request fails.

Clone this wiki locally