# Logging data in to SQL

**URL:** https://discourse.nodered.org/t/logging-data-in-to-sql/83942
**Category:** General
**Created:** [22 December 2023 04:35 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942 "2023-12-22T04:35:43Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [22 December 2023 04:35 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/1 "2023-12-22T04:35:43Z")

</div>

Hi folks,  
I am struggling to log data in to sql server.The flow is as below.  
` { "id": "a1c0b421efb5920a", "type": "inject", "z": "f11c6d5ea7db963e", "name": "ping", "props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "data1", "payloadType": "global", "x": 350, "y": 160, "wires": [[ "0c3376d527d8aab2"] ] }, { "id": "0c3376d527d8aab2", "type": "MSSQL", "z": "f11c6d5ea7db963e", "mssqlCN": "e02ffe57d2be552f", "name": "", "query": "INSERT INTO FLOWMETER\n(PERIOD,FLOWRATE1,TOTAL1,FLOWRATE2,TOTAL2,FLOWRATE3,TOTAL3)\nVALUES\n(GETDATE(),{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}})\n", "outField": "payload", "x": 540, "y": 160, "wires": [[ "1ab6dbcbc5489960"] ] }, { "id": "1ab6dbcbc5489960", "type": "debug", "z": "f11c6d5ea7db963e", "name": "debug 4", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 680, "y": 160, "wires": [] }, { "id": "e02ffe57d2be552f", "type": "MSSQL-CN", "name": "", "server": "localhost", "encyption": false, "database": "PRESS_LOG" } ]`  
Please help!

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

---

<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: [22 December 2023 07:04 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/2 "2023-12-22T07:04:24Z")

</div>

Hi, first get rid of that 7y old problematic node and install mssql-plus (see: [Mssql not sending data to database using mustache format - #4 by Steve-Mcl](https://discourse.nodered.org/t/mssql-not-sending-data-to-database-using-mustache-format/83527/4))

Then, stop using dynamic queries (to avoid SQL injection hacks) and use parameters. Here is an example of how with mssql-plus: [Mssql not sending data to database using mustache format - #2 by Steve-Mcl](https://discourse.nodered.org/t/mssql-not-sending-data-to-database-using-mustache-format/83527/2)

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [22 December 2023 08:08 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/3 "2023-12-22T08:08:59Z")

</div>

I get an error as given when initiating installation of node.

"23-12-22T07:56:18.457Z Install : node-red-contrib-mssql-plus 0.12.1

2023-12-22T07:56:18.474Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-mssql-plus@0.12.1

2023-12-22T07:56:19.599Z [err] npm

2023-12-22T07:56:19.599Z [err] WARN config production Use `--omit=dev` instead.

2023-12-22T07:56:27.529Z [err] npm

2023-12-22T07:56:27.529Z [err] ERR! code

2023-12-22T07:56:27.529Z [err] EBADENGINE

2023-12-22T07:56:27.532Z [err] npm ERR! engine Unsupported engine

2023-12-22T07:56:27.532Z [err] npm ERR! engine Not compatible with your version of node/npm: @azure/core-rest-pipeline@1.13.0

2023-12-22T07:56:27.532Z [err] npm ERR! notsup Not compatible with your version of node/npm: @azure/core-rest-pipeline@1.13.0

2023-12-22T07:56:27.532Z [err] npm

2023-12-22T07:56:27.532Z [err] ERR! notsup Required: {"node":"\>=18.0.0"}

2023-12-22T07:56:27.532Z [err] npm

2023-12-22T07:56:27.532Z [err] ERR! notsup Actual: {"npm":"8.15.0","node":"v16.17.0"}

2023-12-22T07:56:27.536Z [err]

2023-12-22T07:56:27.536Z [err] npm ERR! A complete log of this run can be found in:

2023-12-22T07:56:27.536Z [err] npm

2023-12-22T07:56:27.536Z [err] ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-12-22T07\_56\_19\_570Z-debug-0.log

2023-12-22T07:56:27.572Z rc=1 "

Seems I need to upgrade node red version but I have a project already running on this version.

---

<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: [22 December 2023 08:22 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/4 "2023-12-22T08:22:02Z")

</div>

> [@joey\_ind](#):
>
> ERR! notsup Required: {"node":"\>=18.0.0"}

What version of node are you running?

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [22 December 2023 08:33 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/5 "2023-12-22T08:33:51Z")

</div>

Version - 16.17, but I have another system where this node works which was installed a few months back with this version.

I guess the recent update ( 2 months ago) has rendered it incompatible.

Is there a way to install the previous version of the node?

---

<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: [22 December 2023 08:37 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/6 "2023-12-22T08:37:52Z")

</div>

> [@joey\_ind](#):
>
> Is there a way to install the previous version of the node?

Yes. from inside your node-red folder (i'm guessing `C:\Users\Administrator\.node-red`)...

```bash
npm i node-red-contrib-mssql-plus@0.10.2

```

---

<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: [22 December 2023 08:39 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/7 "2023-12-22T08:39:19Z")

</div>

Forgot to say. Node 16 is now EOL (since sept) so the better solution is to upgrade to v18 LTS

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [26 December 2023 13:16 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/8 "2023-12-26T13:16:16Z")

</div>

Hey,  
That worked ..Thanks!..but what did you want me to find the node red folder?..I ran the command in cmd prompt and it got installed..

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [26 December 2023 13:36 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/9 "2023-12-26T13:36:08Z")

</div>

> [@joey\_ind](#):
>
> I ran the command in cmd prompt and it got installed

What folder were you in when you ran that?

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [27 December 2023 07:43 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/10 "2023-12-27T07:43:32Z")

</div>

I ran from desktop

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [27 December 2023 08:24 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/12 "2023-12-27T08:24:37Z")

</div>

Well that should not have installed it in the right place, so I don't understand how it could have worked.

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [27 December 2023 09:23 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/13 "2023-12-27T09:23:11Z")

</div>

Are you saying the node wouldnt even appear or that it wont work as expected?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [28 December 2023 09:29 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/14 "2023-12-28T09:29:08Z")

</div>

If the node is installed when the current folder is not the folder where the flows and settings files are (for a normal install of node red) then the node will not appear in the palette as, from node-red's point of view, it is not installed.

Edit: If you look in Manage Palette what version of the node does it say is in use?

---

<div class="post-metadata">

### Author: ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)
#### Post date: [29 December 2023 07:46 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/15 "2023-12-29T07:46:09Z")

</div>

Well, it says 0.10.2, which is what I installed..

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 December 2023 10:42 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/16 "2023-12-29T10:42:08Z")

</div>

I have no explanation for how that is.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 January 2024 10:42 UTC](https://discourse.nodered.org/t/logging-data-in-to-sql/83942/17 "2024-01-12T10:42:59Z")

</div>

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