# Reading Rockwell PLC Tags and send to MS SQL Server

**URL:** <https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565>\
**Category:** General\
**Created:** [22 April 2021 19:53 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565 "2021-04-22T19:53:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![WilliDalkeJr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/willidalkejr/32/40600_2.png) [@WilliDalkeJr](https://discourse.nodered.org/u/WilliDalkeJr)\
**Post date:** [22 April 2021 19:53 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/1 "2021-04-22T19:53:19Z")

</div>

Hi guys, i'm trying to work with node red since one week. Watching some videos was possible to have communication with the Rockell PLC, get the variables i need and got communication with the SQL Server.

I don't know how to "treat" the tags list from de flow below and send it to inside SQL server:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d87025e697a63749939f2b987a1857c250c9f850.png)

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

Can you help me on that ?

Kind Regards

Willi Jr

---

<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:** [22 April 2021 22:30 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/2 "2021-04-22T22:30:41Z")

</div>

Since all your values come in to node-red as separate items, you will need to use a join node set to make a key/value object. That will get all your values in one object.

See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

Also, if that is node-red-contrib-mssql you are using, I strongly recommend you replace it with [node-red-contrib-mssql-plus](https://flows.nodered.org/node/node-red-contrib-mssql-plus) there are many benefits not least including prepared procedures and parameters to simplify things and protect you from SQL injection.

---

<div class="post-metadata">

**Author:** ![machadotiago](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/machadotiago/32/23776_2.png) [@machadotiago](https://discourse.nodered.org/u/machadotiago)\
**Post date:** [23 April 2021 14:57 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/3 "2021-04-23T14:57:16Z")

</div>

Can you paste your flow here?  
I would also like to see your SQL Query to insert the data. Maybe the problem is there.

---

<div class="post-metadata">

**Author:** ![WilliDalkeJr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/willidalkejr/32/40600_2.png) [@WilliDalkeJr](https://discourse.nodered.org/u/WilliDalkeJr)\
**Post date:** [23 April 2021 15:34 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/4 "2021-04-23T15:34:57Z")

</div>

Thanks for the help @Steve-Mcl, now we have a group of items and a new and improved node:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cbb0e5ba1195f5e568f8257788da33ba7436ed1a.png)

I know almos nothing in how to write the Query commands, now i think this is the problem as @machadotiago said;

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/beb97ee76881c5d755f42cb94f9259e984e28ca5.png)

I would like to write the tags name in the column "Topic" and the tag value inside the column "Payload"

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/315c773f437a671a23e1c027fb0ae3f272ffc19d.png)

Thanks from Brazil guys

---

<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:** [23 April 2021 15:39 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/5 "2021-04-23T15:39:53Z")

</div>

ah, as you wish to write them individually (instead of one object with all values), you have added the join node for no reason. oops.

So your original flow without the join node should work so long as topic and payload are set. I also would change it to use parameters...

e.g...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d80f1cdf37f26120687d77b2012d57908e6a11e1.png)

---

<div class="post-metadata">

**Author:** ![WilliDalkeJr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/willidalkejr/32/40600_2.png) [@WilliDalkeJr](https://discourse.nodered.org/u/WilliDalkeJr)\
**Post date:** [23 April 2021 16:04 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/6 "2021-04-23T16:04:09Z")

</div>

Thanks for the help again @Steve-Mcl, now it's workig 🙌

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e3af1bfd077f6112393a06b204928c547ef5c3c.png)

---

<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:** [7 May 2021 16:04 UTC](https://discourse.nodered.org/t/reading-rockwell-plc-tags-and-send-to-ms-sql-server/44565/7 "2021-05-07T16:04:13Z")

</div>

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