# Mssql-plus issue with mustache format for server name and user/pwd

**URL:** <https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662>\
**Category:** General\
**Created:** [13 November 2021 07:09 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662 "2021-11-13T07:09:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramesh.rajendran](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ramesh.rajendran/32/50991_2.png) [@ramesh.rajendran](https://discourse.nodered.org/u/ramesh.rajendran)\
**Post date:** [13 November 2021 07:09 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/1 "2021-11-13T07:09:29Z")

</div>

Hi,  
I'm using mssql-plus 0.6.4 version.  
Node red and node js version: not sure, using with Litmus edge

I could not connect to sql using env variable for connection informations. This is helpful for me to connect to different db located in the different location. I tried to create a sub flow for sql that would help me reuse the same flow across different locations with different servers.  
It throws me an errr message  
code: "ESOCKET"  
message: "Failed to connect to :1433 - Could not connect (sequence)

you help would be really appreciable  
I've attached the flow with subflow

`[{"id":"ebc85c42.463a8","type":"subflow","name":"SQLPlus064","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"bf1289cd.07fcb8"}]}],"out":[{"x":300,"y":80,"wires":[{"id":"bf1289cd.07fcb8","port":0}]}],"env":[{"name":"ServerName","type":"str","value":"10.1.2.111"},{"name":"UserName","type":"str","value":"appliUser"},{"name":"Password","type":"str","value":"1234556"},{"name":"DBName","type":"str","value":"DB_DEV"}],"color":"#DDAA99"},{"id":"bf1289cd.07fcb8","type":"MSSQL","z":"ebc85c42.463a8","mssqlCN":"c29068d1.97ef38","name":"","outField":"payload","returnType":0,"throwErrors":1,"query":"Select TOP 10 * FROM TestBenchResult","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"","paramsOptType":"none","params":[],"x":200,"y":80,"wires":[[]]},{"id":"c29068d1.97ef38","type":"MSSQL-CN","z":"ebc85c42.463a8","tdsVersion":"7_4","name":"DB-Con","server":"\"ServerName\"","port":"","encyption":true,"trustServerCertificate":true,"database":"ShopfloorDB_DEV","useUTC":false,"connectTimeout":"50000","requestTimeout":"50000","cancelTimeout":"50000","pool":"5","parseJSON":false,"enableArithAbort":true},{"id":"c81636eb.e7d248","type":"tab","label":"MSSQLPlus-CheckSub","disabled":false,"info":""},{"id":"7c1a36cd.c54a88","type":"inject","z":"c81636eb.e7d248","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":100,"wires":[["30366732.3efba8"]]},{"id":"de6a1325.7c759","type":"debug","z":"c81636eb.e7d248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":440,"y":100,"wires":[]},{"id":"30366732.3efba8","type":"subflow:ebc85c42.463a8","z":"c81636eb.e7d248","name":"","env":[{"name":"ServerName","value":"10.1.2.111","type":"env"},{"name":"Password","value":"123456789","type":"str"}],"x":300,"y":80,"wires":[["de6a1325.7c759"]]}]`

please let me know if you need any further details.

we really need this as we have more locations for which we cannot create different flows for same set of actions

Thanks  
Ramesh R

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 November 2021 08:28 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/2 "2021-11-13T08:28:41Z")

</div>

I think this is not possible (via env variables) as the credentials are stored and encrypted separately - outside the flow file.  
When exporting the flow, the credentials are not included (security).

---

<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:** [13 November 2021 09:12 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/3 "2021-11-13T09:12:59Z")

</div>

Hi. I'm not able to provide assistance right now however I will say, env variables should work. Instead of using a subflow, could you try real env vars (in the executing environment - before you launch node-red) - do they work for you?

---

<div class="post-metadata">

**Author:** ![ramesh.rajendran](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ramesh.rajendran/32/50991_2.png) [@ramesh.rajendran](https://discourse.nodered.org/u/ramesh.rajendran)\
**Post date:** [13 November 2021 09:18 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/4 "2021-11-13T09:18:00Z")

</div>

But in the documentation, it is mentioned in the features list

 ![NodeRed-Feature](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47244bd37f26f2c888582b594a3c16581e872fbd.png)

Thanks  
Ramesh R

---

<div class="post-metadata">

**Author:** ![ramesh.rajendran](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ramesh.rajendran/32/50991_2.png) [@ramesh.rajendran](https://discourse.nodered.org/u/ramesh.rajendran)\
**Post date:** [13 November 2021 09:21 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/5 "2021-11-13T09:21:33Z")

</div>

Hi @Steve-Mcl ,  
Sorry for my poor knowledge. I'm new to node-red.  
So please excuse me if this may be a basic question

How do I set Environment variable for a normal flow?  
Because I could not set in the executing env, I even googled but in vain

Thanks

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 November 2021 09:22 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/6 "2021-11-13T09:22:10Z")

</div>

Ah ok, i was not aware, that is a useful feature in these situations (if it works ofcourse ;))

---

<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:** [13 November 2021 09:32 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/7 "2021-11-13T09:32:07Z")

</div>

Before launching node-red, set environmental variables in your terminal.

E.g. Windows CMD...

```bash
set server=192.168.0.99
node-red

```

E.g. Linux terminal

```bash
export server=192.168.0.99
node-red

```

Then use the variable...

E.g. `{{server}}`

( try double brackets instead of triple )

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 November 2021 09:40 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/8 "2021-11-13T09:40:31Z")

</div>

No. Use. ${server}. You aren’t using mustache here. And it can only be for the complete property.  
see - [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables)

---

<div class="post-metadata">

**Author:** ![ramesh.rajendran](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ramesh.rajendran/32/50991_2.png) [@ramesh.rajendran](https://discourse.nodered.org/u/ramesh.rajendran)\
**Post date:** [13 November 2021 10:00 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/9 "2021-11-13T10:00:35Z")

</div>

Sorry both ${server} and {{server}} not working

---

<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 2022 10:00 UTC](https://discourse.nodered.org/t/mssql-plus-issue-with-mustache-format-for-server-name-and-user-pwd/53662/10 "2022-01-12T10:00:49Z")

</div>

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