Hi there - I struggled with this using the mssql and tedious packages, tried using the optional msnodesqlv8 package with mssql, pored through debug logs and the mssql/tedious packages themselves, and am thoroughly convinced that any current solution cannot rely on those packages. However, here is a solution using the msnodesqlv8 package and the latest ODBC driver 18 for SQL Server without tedious or mssql.
const sql = require('msnodesqlv8');
// Connection string for Azure SQL (Lakehouse)
const connectionString = `
Driver={ODBC Driver 18 for SQL Server};
Server=<your-endpoint.datawarehouse.fabric.microsoft.com>;
Database=<your-database-name>;
Authentication=ActiveDirectoryServicePrincipal;
UID=<your-app-registration-id>@<your-tenant-id>;
PWD=<your-app-registration-secret>;
`;
const query = 'SELECT TOP 10 * FROM sys.tables';
sql.open(connectionString, (err, conn) => {
if (err) {
console.error('Connection error:', err);
return;
}
conn.query(query, (err, rows) => {
if (err) {
console.error('Query error:', err);
} else {
console.log('Query results:', rows);
}
conn.close();
});
});