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 .
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}'`