MQTT data logs in SQL server always shifting

I am using Node-Red to log MQTT data in SQL server. It works fine for a few minutes and it won't write on to proper columns. Appreciate it if anyone helps me to fix this issue.

Following is a sample log,

Here is my Flow,

Welcome here.

The join node can introduce complexities - what if one of the values is not arriving ?
Attach a debug node to the join node and verify if you are always receiving all the required data.

The function node has an error (see the red triangle).
Attach a debug node to the function and analyze what statement it is producing before it goes into the db.

If the join node is in array mode this will happen due to the order in which input data arrives.

Change the join to object mode and use parameters in the mssql node to guarantee order of columns