Home Convert table to JSON with an specific path
Reply: 0

Convert table to JSON with an specific path

Rafa Barragan
1#
Rafa Barragan Published in 2017-12-06 18:20:32Z

I'm new with JSON format and i want to convert a Table from SQL to this format, i have something like this:

The row 1 and 2 belongs to the same Product, but the Area Column shows different attributes. TheJSON should have a node for each operation and subnode whit each attribute. I use this code:

SELECT 
    KeyOp, Office, OType, Channel, SubType, Operation
    , Area [Des.Area], IDOperation [Des.IDOperation], Ticket [Des.Ticket]
    , Currency [Des.Currency], Account [Des.Account], Ammount [Des.Ammount] 
FROM dbo.Table1 
FOR JSON PATH, ROOT('JSONPATH')

but i get this behavior:

Is it possible to join this two lines? I'm using SSMS 2012.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.328212 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO