Reading data from S7-300 and want to log in MSSQL need function or query

Hi,

I am new to node red and trying to build a Dashboard as a hobbiest . For this i am reading data from Siemens PLC data block and i want to store that data in MSSQL and not able to write function for it .

above is the PLC tag DB124,Word0 as shown in picture

i have tried to make function but it is now successful at all .

Can any body here help me in writing a function that can export data to my Data base having table "nodered" with column "recipe name"

Can I ask why, as a hobbyist, you want to use mssql?
Why do you want to store the data? There may well be better and simpler ways.

I want to learn MSSQL Databases as well with this hobby project .

i want to make a dashboard using Grafana for that i need to store data.

Hi Peter.

First things first ...
Are you usung mssql-plus node?
That node permits you to use any msg property to send the SQL statement. However, on most MSSQL nodes, you do NOT use msg.topic.

2ndly. Read the extensive built in help for the mssql-plus node. It has examples and info to get you going.

3rd, why not take advantage of mustache or better still parameters in the MSSQL node instead of building a string SQL statement in a function?

Lastly, on line 6 - that is not how you concatenate strings and variables. Perhaps you are new to JavaScript too? Try using + operator to concatenate or use a template string `insert ..... Where field ='${variable}'`

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