# Dynamically change the ip of the connection config MSSQL

**URL:** <https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886>\
**Category:** General\
**Created:** [1 July 2021 10:52 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886 "2021-07-01T10:52:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuki\_1990](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tuki\_1990](https://discourse.nodered.org/u/tuki_1990)\
**Post date:** [1 July 2021 10:52 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/1 "2021-07-01T10:52:47Z")

</div>

Hello! i'm starting with node-Red and i have a trouble with it. I'm using MSSQL node from: node-red-contrib-mssql-plus.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d6ed3fed05f0c7a953a654bb23cd5f66eb96ea6b.png)  
and i want to change dinamically the ip of the connection with a flow variable it is possible? thanks

---

<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:** [1 July 2021 13:24 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/2 "2021-07-01T13:24:07Z")

</div>

> [@tuki\_1990](#):
>
> i want to change dinamically the ip of the connection with a flow variable it is possible? thanks

No, but you can use an ENV variable.

e.g. `${SQL_SERVER_IP}`

---

<div class="post-metadata">

**Author:** ![tuki\_1990](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tuki\_1990](https://discourse.nodered.org/u/tuki_1990)\
**Post date:** [1 July 2021 13:29 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/3 "2021-07-01T13:29:26Z")

</div>

Thanks! but its possible to change the value of this environment in a function 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:** [1 July 2021 14:10 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/4 "2021-07-01T14:10:10Z")

</div>

Yes, kinda, but - environment variables are only read when node-red starts.

Ps, if you don't reply directly to my post I don't get a notification - so I don't know if you've replied until I look at the forum again.

---

<div class="post-metadata">

**Author:** ![tuki\_1990](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tuki\_1990](https://discourse.nodered.org/u/tuki_1990)\
**Post date:** [1 July 2021 14:14 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/5 "2021-07-01T14:14:05Z")

</div>

okay sorry Steve im totally new, and last question its possible to connect to sql via a function expression? i'm trying it but its not woking

---

<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:** [1 July 2021 14:18 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/6 "2021-07-01T14:18:17Z")

</div>

When use say connect do you mean provide an IP and username etc?

It's not possible to pass in config parameters at runtime. This is the case with most config nodes unless it has been explicitly designed to accept parameters after creation.

Why do you wish to send IP address parameters? It is easy enough to modify the config node in the Node red editor

---

<div class="post-metadata">

**Author:** ![tuki\_1990](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tuki\_1990](https://discourse.nodered.org/u/tuki_1990)\
**Post date:** [1 July 2021 14:21 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/7 "2021-07-01T14:21:49Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c059386f7f5a089e62650806a537b9948291b1d3.png)  
i want to do something like this but is not working....

---

<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:** [1 July 2021 14:25 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/8 "2021-07-01T14:25:44Z")

</div>

Do you get an error?

Have you added `mssql` in settings.js function context?

Also, what is `res.send` supposed to do?

Lastly, you can't `return msg` due to async processing, you need to do `node.send(msg)` in the callback.

---

<div class="post-metadata">

**Author:** ![tuki\_1990](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tuki\_1990](https://discourse.nodered.org/u/tuki_1990)\
**Post date:** [1 July 2021 14:30 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/9 "2021-07-01T14:30:41Z")

</div>

yes i did it 🙂  
appears this error:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4eb4cee705368d110014d3549a4d3273a08ed9d7.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:** [1 July 2021 14:32 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/10 "2021-07-01T14:32:32Z")

</div>

Thats a problem with you coding - you will have to read the MSSQL docs

Alternatively, use mssql-plus node that has been designed to simplify life.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 July 2021 14:03 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/11 "2021-07-03T14:03:01Z")

</div>

Looks to me as though the SQL server is wanting an SSL encrypted connection and you haven't passed it one.

Also, the instructions for the mssql module suggest that you need a `sql.connect` but you've used `sql.Request` which wants a pool or transaction as an argument, maybe not your config object?

---

<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:** [1 September 2021 14:03 UTC](https://discourse.nodered.org/t/dynamically-change-the-ip-of-the-connection-config-mssql/47886/12 "2021-09-01T14:03:40Z")

</div>

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