# MS SQL to Nested JSON (without using JSON PATH)

**URL:** <https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091>\
**Category:** Integrator.io\
**Tags:** sql, grouping, microsoft-sql, json\
**Created:** [November 30, 2021, 2:16pm UTC](https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091 "2021-11-30T14:16:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronmccallister](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ronmccallister](https://connective.celigo.com/u/ronmccallister)\
**Post date:** [November 30, 2021, 2:16pm UTC](https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091/1 "2021-11-30T14:16:10Z")

</div>

I am needing to convert a query from MS SQL into a nested JSON. The export from MS SQL looks like this:

> {  
> "page\_of\_records": [  
> {  
> "record": {  
> "RegistrationId": 13,  
> "ModelId": "1",  
> "NotifyReplacement": true,  
> "InstallationDate": "2018-05-05T00:00:00.000Z",  
> "CustomerFirstName": "David",  
> "CustomerLastName": "Test",  
> "CustomerEmail": "[bob@gmail.com](mailto:bob@gmail.com)",  
> "CustomerPhone": "4236549871",  
> "ContractorName": "Me Contractor",  
> "ContractorEmail": "[mac@gmail.com](mailto:mac@gmail.com)",  
> "ContractorPhone": "4233333370",  
> "CustomerCount": 2  
> }  
> },  
> {  
> "record": {  
> "RegistrationId": 14,  
> "ModelId": "1",  
> "NotifyReplacement": true,  
> "InstallationDate": "2015-01-12T00:00:00.000Z",  
> "CustomerFirstName": "Daniel",  
> "CustomerLastName": "test",  
> "CustomerEmail": "[fred@gmail.com](mailto:fred@gmail.com)",  
> "CustomerPhone": "4235244562",  
> "ContractorName": "Me Contractor",  
> "ContractorEmail": "[mac@gmail.com](mailto:mac@gmail.com)",  
> "ContractorPhone": "4235244562",  
> "CustomerCount": 2  
> }  
> }  
> ]  
> }

The result should look like this:

> {  
> "ContractorName": "Me Contractor",  
> "ContractorEmail": "[mac@gmail.com](mailto:mac@gmail.com)",  
> "ContractorPhone": "4233333370",  
> "user": {  
> "customer": [  
> {  
> "CustomerFirstName": "David",  
> "CustomerLastName": "Test",  
> "CustomerEmail": "[bob@gmail.com](mailto:bob@gmail.com)"  
> },  
> {  
> "CustomerFirstName": "Daniel",  
> "CustomerLastName": "Test",  
> "CustomerEmail": "[fred@gmail.com](mailto:fred@gmail.com)"  
> }  
> ]  
> }  
> }

It appears that the ‘grouping mechanism’ isn’t available when it is directly from a query (IE: not a file). I would want to ‘group by’ the ContractorEmail. What are some approaches that may help with this?

---

<div class="post-metadata">

**Author:** ![katelarson](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@katelarson](https://connective.celigo.com/u/katelarson)\
**Post date:** [December 1, 2021, 5:01pm UTC](https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091/2 "2021-12-01T17:01:09Z")

</div>

Hi @ronmccallister -  
I'm checking with our internal team to see if someone can provide assistance here. Please review our [Office Hours](https://docs.celigo.com/hc/en-us/articles/360045798291-Which-Office-Hours-session-should-I-attend-) information to determine if that is a possibility for you as well.   
Thanks,

Kate

---

<div class="post-metadata">

**Author:** ![andrewnelson](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@andrewnelson](https://connective.celigo.com/u/andrewnelson)\
**Post date:** [January 24, 2022, 8:00pm UTC](https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091/3 "2022-01-24T20:00:45Z")

</div>

Hi there, I am having the same issue where i am pulling a record from a database that is coming across in multiple lines that i need grouped into a single JSON object. Did you find a resolution on this?

---

<div class="post-metadata">

**Author:** ![katelarson](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@katelarson](https://connective.celigo.com/u/katelarson)\
**Post date:** [January 26, 2022, 5:47pm UTC](https://connective.celigo.com/t/ms-sql-to-nested-json-without-using-json-path/1091/4 "2022-01-26T17:47:16Z")

</div>

@andrewnelson - We recommend opening a [ticket](https://celigosuccess.zendesk.com/) so Support can review your configuration and work with you on a solution. Thanks!
