# MSSQL, two input problem

**URL:** <https://discourse.nodered.org/t/mssql-two-input-problem/14276>\
**Category:** General\
**Created:** [13 August 2019 11:49 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276 "2019-08-13T11:49:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![petrdolejs](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@petrdolejs](https://discourse.nodered.org/u/petrdolejs)\
**Post date:** [13 August 2019 11:49 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/1 "2019-08-13T11:49:48Z")

</div>

Hello, I'working on project where I read data from energy meter and I should send them on MSSQL.  
My problem is in MSSQL node. I have two inputs but when I have in query this line

SET @total\_Ea\_Import = {{{payloadTotal\_Ea\_Import}}};

It show me this error

"RequestError: Incorrect syntax near ';'."

Here is my whole query from MSSQL:

DECLARE @total\_Ea\_Import float  
DECLARE @total\_Er\_Import float  
SET @total\_Ea\_Import = {{{payloadTotal\_Ea\_Import}}};  
SET @total\_Er\_Import = {{{payloadTotal\_Er\_Import}}};  
INSERT INTO iEM3000  
(Total\_Ea\_Import,Total\_Er\_Import)  
VALUES  
(@total\_Ea\_Import,@total\_Er\_Import )

The weirdest thing is if I instead of query I post I use this query:

DECLARE @total\_Ea\_Import float  
DECLARE @total\_Er\_Import float  
SET @total\_Ea\_Import = {{{payloadTotal\_Er\_Import}}};//here is change, instead of Ea is Er  
SET @total\_Er\_Import = {{{payloadTotal\_Er\_Import}}};  
INSERT INTO iEM3000  
(Total\_Ea\_Import,Total\_Er\_Import)  
VALUES  
(@total\_Ea\_Import,@total\_Er\_Import )

It works but I've just got the same data twice. So I think the problem is in that line with Total Active Energy Import-\>Float32-\>Ea Import  
And I tried to copy everything from that downside line that work and just change Er and Ea but still don't work.

Anyone who have an idea what is wrong? ☹  
 ![NodeRedForum](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a8ac293850c5031ffccc17a159fb27d32d678174.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 August 2019 11:56 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/2 "2019-08-13T11:56:22Z")

</div>

The MSSQL node won't magically join the two messages together.  
It just sees a message does it stuff and them when the next message comes in it does it stuff again.

You need to Join the two messages together before the MSSQL node take a look at the JOIN node.

---

<div class="post-metadata">

**Author:** ![petrdolejs](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@petrdolejs](https://discourse.nodered.org/u/petrdolejs)\
**Post date:** [13 August 2019 12:10 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/3 "2019-08-13T12:10:57Z")

</div>

I don't need join them together. I need to send data coming from node Ea Import to column (in database) called Total\_Ea\_Import and data coming from node Er Import to column (in database) called Total\_Er\_Import. But that line in query

SET @total\_Ea\_Import = {{{payloadTotal\_Ea\_Import}}};

can't set value from payloadtotal\_Ea\_Import to @total\_Ea\_Import.  
When I deploy it without this line, it works but in column Total\_Ea\_Import is null and Total\_Er\_Import is correct. So I believe the problem is in that line or in nodes Total Active Energy Import-\>Float32-\>Ea Import.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 August 2019 12:14 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/4 "2019-08-13T12:14:32Z")

</div>

So if the first message that the MSSQL node receives is from your Er import node it doesn't contain data from the Ea import node...

---

<div class="post-metadata">

**Author:** ![petrdolejs](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@petrdolejs](https://discourse.nodered.org/u/petrdolejs)\
**Post date:** [13 August 2019 12:33 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/5 "2019-08-13T12:33:22Z")

</div>

Okey, that make sense! I'll try that JOIN node.  
I also watched the video from Opto ([https://www.youtube.com/watch?v=cO8QpyUnEwg](https://www.youtube.com/watch?v=cO8QpyUnEwg)) and there is no JOIN node but I'll try something with that. 🙂

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 August 2019 12:38 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/6 "2019-08-13T12:38:52Z")

</div>

Actually I'm not sure that is going to solve the problem, given your current flow (but only seeing picture its rather difficult to know exactly what you are doing)

But you can't get data from two separate inputs and assume they will be joined which is what you appear to be doing. Perhaps you can link to the point in the video where two inputs are merged?

---

<div class="post-metadata">

**Author:** ![petrdolejs](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@petrdolejs](https://discourse.nodered.org/u/petrdolejs)\
**Post date:** [13 August 2019 12:56 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/7 "2019-08-13T12:56:21Z")

</div>

Yeah. there are not two inputs. I overlooked. Sorry for wasting your time with that video. But I think I know what you mean so I'll try somehow join them together and we'll see.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 August 2019 14:58 UTC](https://discourse.nodered.org/t/mssql-two-input-problem/14276/8 "2019-08-13T14:58:20Z")

</div>

See this recipe in the cookbook for joining messages from two sources  
[https://cookbook.nodered.org/basic/join-streams](https://cookbook.nodered.org/basic/join-streams)
