# Iterating through message's child array in SQL Query

**URL:** <https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089>\
**Category:** General\
**Created:** [14 July 2020 23:36 UTC](https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089 "2020-07-14T23:36:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bppuck](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bppuck](https://discourse.nodered.org/u/bppuck)\
**Post date:** [14 July 2020 23:36 UTC](https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089/1 "2020-07-14T23:36:35Z")

</div>

Hi,  
I need help figuring out how to instantiate a SQL variable with an array value, or find another method to accomplish iterating through a child array within the message. The results from my attempt are producing empty results:

{"jsonVersion":1,"deviceProperties":{"version":{"value":"1.0"},"deviceId":{"value":"a123456789"}},"records":[{"dataType":{"value":"weightMeasurement"},"weight":{"value":12,"unit":"lbs"},"measurementTime":{"value":"2020-07-08 17:39:59"}}]}

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4e9c8590c9b74812f0e4b2ee973be9f71ce0976.png)

Using: node-red-contrib-mssql-plus v0.4.4

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 July 2020 23:57 UTC](https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089/2 "2020-07-14T23:57:49Z")

</div>

Hi, in this scenario, I move the logic outside of SQL and back to node-red.

E.g. your insert data is in an array, send it through a split node, then you will get multiple msgs sent to the SQL node where you would insert each record.

---

<div class="post-metadata">

**Author:** ![bppuck](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bppuck](https://discourse.nodered.org/u/bppuck)\
**Post date:** [15 July 2020 00:18 UTC](https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089/3 "2020-07-15T00:18:00Z")

</div>

Thank you for the quick response. I'll learn how to split it first then.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 September 2020 00:28 UTC](https://discourse.nodered.org/t/iterating-through-messages-child-array-in-sql-query/30089/4 "2020-09-13T00:28:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
