SQL server table data into JSON -


i have data table stored in sql server , wanna convert json creating chart json data(using d3js). want convert sql server data json. suppose table name salary (empname, salary) query how parse data table json further use.

one of top feature of mssql server 2016 built in support of json. can write simple query format query results json in mssql using json in select statement. checkout below example.

using path mode json clause

 select salesordernumber 'order.number',            orderdate 'order.date',            unitprice 'product.price',            orderqty 'product.quantity'     sales.salesorderheader h       inner join sales.salesorderdetail d         on h.salesorderid = d.salesorderid     json path 

output of json path mode

[   {     "order":{         "number":"so43659",         "date":"2011-05-31t00:00:00"       },     "product":{          "price":2024.9940,          "quantity":1      }   },   {     "order":{ "number":"so43659“ },     "product":{"price":2024.9940}   } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -