# Can we use values from sql statement to be inserted in an array in a document

**URL:** <https://discuss.elastic.co/t/can-we-use-values-from-sql-statement-to-be-inserted-in-an-array-in-a-document/58289>\
**Category:** Logstash\
**Created:** [August 17, 2016, 7:45pm UTC](https://discuss.elastic.co/t/can-we-use-values-from-sql-statement-to-be-inserted-in-an-array-in-a-document/58289 "2016-08-17T19:45:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vtangutoori](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@vtangutoori](https://discuss.elastic.co/u/vtangutoori)\
**Post date:** [August 17, 2016, 7:45pm UTC](https://discuss.elastic.co/t/can-we-use-values-from-sql-statement-to-be-inserted-in-an-array-in-a-document/58289/1 "2016-08-17T19:45:59Z")

</div>

Hi,  
I am trying to import data from SQL Server and i need to create one field in the document as an array and add all the values related to the document from child table. please see the example below.

Table 1: Manufacturer

Manufacturer\_Id Make Year  
1 Mercedes 2017  
2 BMW 2017

Table 2: Models

Manufacturer\_Id Model\_Id Model Name  
1 1001 C300  
1 1002 C350  
2 1003 328i  
3 1004 328Xi

I want the document to look something like the below.

{  
"\_id": 1  
"manufacturer": "Mercedes"  
"year": 2017  
"model": ["C300", "C350"]  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:42am UTC](https://discuss.elastic.co/t/can-we-use-values-from-sql-statement-to-be-inserted-in-an-array-in-a-document/58289/2 "2017-07-06T04:42:59Z")

</div>

Closed on July 6, 2017, 4:42am UTC


