Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
sql table's data to array javascript

I have JavaScript code below that connect to the database and SELECT table

//Connect to database
  var sql = require("mssql");

  var config = {
  user: '****',
  password: '*****',
  server: '****',
  databse:'****',
  };
  
  sql.connect(config)
      var request = new sql.Request();
      // query to the database and get the records
      request.query("select * from Test ")

below is the terminal output.

 recordset: [
    { ID: '0      ', Name: 'Test1     ', Age: '80        ' },
    { ID: '1      ', Name: 'Test2      ', Age: '55        ' }
  ],

So I need to make array below take all data from recordset, so I can use the array in other functions

var users = [{}]

when open the page on the browser the var users should look

users = [
    { ID: '0', Name: 'Test1', Age: '80' },
    { ID: '1', Name: 'Test2', Age: '55' }
  ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you already have recordset in desired format and you want it to be users, you can do this:

var users = recordset; 

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!