# Logging data in to MSSQL

**URL:** <https://discourse.nodered.org/t/logging-data-in-to-mssql/67539>\
**Category:** Industrial\
**Created:** [10 September 2022 05:21 UTC](https://discourse.nodered.org/t/logging-data-in-to-mssql/67539 "2022-09-10T05:21:02Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 September 2022 09:43 UTC](https://discourse.nodered.org/t/logging-data-in-to-mssql/67539/13 "2022-09-10T09:43:41Z")

</div>

You have several mistakes in your flow.

1. As @zenofmud points out, you have undeclared variables in your flow
  - NB: The function is utterly pointless here

2. You have the MSSQL-PLUS node set to use the SQL in the UI - BUT - you are attempting to pass a SQL STRING in via `msg.topic`
  - NB: This is the least safe way of doing SQL - you should use parameters in the UI to avoid SQL injection

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e4146af73aaece71874949ae04e3de2be2e9aec.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c4a3416b7d3ea0c9408b6877c96ab5e7174e31cc.png)

Demo flow...

```auto
[{"id":"ee57a1d4778d19aa","type":"MSSQL","z":"49f61d916c8f6022","mssqlCN":"358e71158db79bf8","name":"read","outField":"payload","returnType":0,"throwErrors":1,"query":"INSERT INTO pco2 \r\n (door_status,temp,upper_limit,lower_limit) \r\nVALUES\r\n (@doorstatus, @temp, @upper_limit, @lower_limit)\r\n","modeOpt":"queryMode","modeOptType":"query","queryOpt":"payload","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"rows","rowsType":"msg","params":[{"output":false,"name":"door_status","type":"VarChar","valueType":"global","value":"dipco2lwr","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"temp","type":"Float","valueType":"global","value":"rtdpco2","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"upper_limit","type":"Float","valueType":"global","value":"pco2-low","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"lower_limit","type":"Float","valueType":"global","value":"pco2-up","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1490,"y":100,"wires":[[]]},{"id":"358e71158db79bf8","type":"MSSQL-CN","tdsVersion":"7_4","name":"","server":"localhost","port":"1433","encyption":false,"trustServerCertificate":false,"database":"DATA","useUTC":false,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5","parseJSON":false,"enableArithAbort":true}]

```

---

_[View the full topic](https://discourse.nodered.org/t/logging-data-in-to-mssql/67539)._
