Insert data to MSQLL

Need help!
I am waiting 2 groove Rio to arrive in the meantime I am working in the project that consist to capture the machine cycles and hours of operation, There are two nodes that can work in my project but for a particular reason that I don’t understand is when using both ( counter and hourglass nodes ) with mssql there is a message showing syntax error, I have used the node mssql in another projects sending vibration data to a mssql with no problem, can anyone tell me what I am doing wrong.

SQL query- counter
Also I am sharing the query

Welcome to the forums.

Please expand both payloads in the debug tab and take another screenshot.
Also if you can help us understand which debug tab message belongs to which debug node, that would really helpful.
With them folded up like they are, we cant see what the JSON structure is like.
Looks like the issue has nothing to do with the top 11 nodes, so the focus can be on the bottom 7?

The error is because the count value is larger than what fits in the integer data type. You will need to use a BIGINT in your database to fit that number.


Yes the focus will be the 7 nodes

Hi I change in my database to BIGINT but persist the syntaxis error

Did you change your SQL as well?

Screen shot of mssql server
Yes I change the column count to bigint

So you have DECLARE @count bigint?

Yes also in the mssql node I change to bigint in declare
I have been struggling almost a week and I was wondering if there is a different way to do this since it’s no working, I have try with other counters for example countula and also the same issue.

The debug shows the error near ;
I would try and remove the ; after the count and place it after the insert at the end. (Or use two, one in each location).

Is there a “query” field that has been put in the msg object after the MSSQL PLUS node that you can show us.

Yes I have try removing it after the count, also adding it at the end in Insert but still showing the error

Attached the message object screen shot after the MSSQL Plus node

it seems that the message flows through the MSSQL node and counts but does not send the count number to the database

Have you tried just inserting the payload rather than doing the set @count thing?
Seems to be double handling and I am not sure why that’s required.
Something like this perhaps (don’t copy paste this, use it as a guide only)…

INSERT INTO ciclo (count, TimeStamp) VALUES ( ‘{{{msg.payload}}}’. CURRENT_TIMESTAMP);

EDIT, also, I know the line feed / carriage returns are probably Ok in the insert statement, but they make me uncomfortable / question if they really are Ok, so try putting in one flat line.

1 Like

Your count value is not in the payload, it is in the msg object. So payload.count is nothing which shows in the query output:


Change your {{{payload.count}}} to just {{{count}}}.

1 Like

Hi finally flow is working fine, thank you for your support Philip and Beno, it has been a great learning

Cheers from Honduras, Central America

@renedavid6 Could please post the final insert statement so we could see and learn what got it going.

Thanks and glad to hear you got up and running.

Hello attached the screen shots