Created
January 19, 2019 16:09
-
-
Save pirosuke/69ab114f8f8a5ee173cfbf46424d0a45 to your computer and use it in GitHub Desktop.
A Sample To Fetch Data From MSSQL using Windows Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const msnodesql = require("msnodesqlv8"); | |
async function fetchDataList(conn, query) { | |
return new Promise((resolve, reject) => { | |
conn.query(query, (err, rows) => { | |
if (err !== null) { | |
reject(err); | |
return; | |
} | |
resolve(rows); | |
}); | |
}); | |
} | |
async function main() { | |
const connectionString = "server=SERVER_NAME\\INSTANCE_NAME;Database=DATABASE_NAME;Trusted_Connection=Yes;Driver={SQL Server Native Client 11.0}"; | |
msnodesql.open(connectionString, async (err, conn) => { | |
const resultList = await fetchDataList(conn, 'select * from dbo.TABLE_NAME'); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment