How to connect to an mssql db

How am I able to connect to our internal SQL databases using mssql from npm?

I checked out the documentation, though am still at a loss. It all comes in snippets without an all-inclusive example.

Is there some tutorial or sample code I could emulate?

Perhaps a repository of code examples from JA would be beneficial.

Hi George

The below basic code should work as expected, you just need to substitute in your specific DB details for the connection Config and the query. Also remember to include the ‘mssql’ NPM package as a dependency

export async function run() {

    var sql = require("mssql");

    // config for your database
    var config = {
        user: '', // username
        password: '', // password
        server: '', // your server address
        database: '' // your DB ID
    };

    let tableName = 'someTableName';
    // connect to your database
     await sql.connect(config);

     let results = await sql.query(`select * ${tableName}`);
     
     console.log("Results: ", JSON.stringify(results))

}