# Best practice mssql node

**URL:** <https://discourse.nodered.org/t/best-practice-mssql-node/99386>\
**Category:** General\
**Created:** [14 October 2025 12:46 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386 "2025-10-14T12:46:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filip\_Top](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@Filip\_Top](https://discourse.nodered.org/u/Filip_Top)\
**Post date:** [14 October 2025 12:46 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/1 "2025-10-14T12:46:10Z")

</div>

I'm using data from the database to update multiple screens every 5 min from the database.  
To do this, I need to run several queries in the same database.

What is the best practice, make a flow for every query with his own MSSQL node, like this example (the query is in the inject node):

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b018f67f024e6a4cca9c147c2291022360328b3.png)

Or do I use function blocks where I place the query in and connect them to the MSSQL node:

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

I haven't tried the second way so I don't know if this works.  
I noticed that having multiple MSSQL nodes that are triggered at the same time causes problems.

Thanks for any ideas 🙂  
Filip Top

---

<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:** [14 October 2025 13:21 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/2 "2025-10-14T13:21:52Z")

</div>

> [@Filip\_Top](#):
>
> I noticed that having multiple MSSQL nodes that are triggered at the same time causes problems.

Typically, I would not do this in parallel - but even more-so not with the OLD, less capable, very buggy, potentially dangerously out-of-date `MSSQL` node.

Make sure you are using the in-support, up-to-date `node-red-contrib-mssql-plus` node

As for other recommendations, don't use `{{var}}` syntax in your queries - always use parameters (to avoid risk of SQL injections)

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [14 October 2025 15:26 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/3 "2025-10-14T15:26:44Z")

</div>

I concur with @Steve-Mcl that it is not a good I idea to trigger concurrent queries. What I always do is define a generic node-group which is reused across all flows via link-calls.  
In that group I put some standard protection & error management, e.g., a rate limiter (ensuring a minimum "breather" between queries), error catching/handling, retries etc.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [14 October 2025 15:31 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/4 "2025-10-14T15:31:14Z")

</div>

And... be sure to observe the best practices for query creation and execution... injection attacks for example can be a key issue using SQL. Never hurts to structure SQL queries so they are not obviously vulnerable.

---

<div class="post-metadata">

**Author:** ![Filip\_Top](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@Filip\_Top](https://discourse.nodered.org/u/Filip_Top)\
**Post date:** [15 October 2025 08:46 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/5 "2025-10-15T08:46:17Z")

</div>

Thank you all for the input, where some very good idea's.

I installed the newer `node-red-contrib-mssql-plus` and found it a very good idea to build a subflow for connecting to the database. This way I have only one place to be if something changes. But I don't really know how to optimize it, so I build something simple like this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92350d195257eec9a7e1c28918436bd76710bda7.png)

Does this make sense or is it the most stupid idea?

---

<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:** [15 October 2025 09:32 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/6 "2025-10-15T09:32:18Z")

</div>

when you put a node like this (in a subflow) each instance of the subflow will create a separate connection to the database. If this is azure, you can easily hit connection limits.

You are better off using link-call as pointed out by @omrid

example: [Can Node Mssql running in many flow? - #5 by bakman2](https://discourse.nodered.org/t/can-node-mssql-running-in-many-flow/93954/5)

---

<div class="post-metadata">

**Author:** ![Filip\_Top](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@Filip\_Top](https://discourse.nodered.org/u/Filip_Top)\
**Post date:** [15 October 2025 10:06 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/7 "2025-10-15T10:06:46Z")

</div>

Thank you Steve. It was not clear to me what the difference was between a subflow and a link call.  
So I have this in the end:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4971a8156bb6c5751f03414c1d57d0f69414519.png)  
Two more questions:

1. What is the best place to put the group? I have it now on my flow, but I have multiple flows. Do I make a flow only for this one, or can I still put it in a subflow? (or is it than creating multiple connections)
2. The status (like here done), can I show it in the link call.

I know, a lot of questions but I try to get it right from the first time.  
Thanks

---

<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:** [15 October 2025 10:20 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/8 "2025-10-15T10:20:02Z")

</div>

You can put the link call group (with the db node) on a separate flow tab. It does not need to be on the same tab as the calling flow.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [15 October 2025 10:32 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/9 "2025-10-15T10:32:17Z")

</div>

1. You can place the node-group anywhere you wish (even in its own tab) and call it from any flow tab in the editor. I recommend calling the entry point (link-in) of the group it with a dynamic address (`msg.target`), not by node Id, to protect against Id changes (import, copy/paste etc.).
2. I am not familiar with a way to show status on a link-call. @Steve-Mcl ?
3. I would move the `split` node outside of the group.

---

<div class="post-metadata">

**Author:** ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)\
**Post date:** [17 October 2025 11:40 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/10 "2025-10-17T11:40:19Z")

</div>

It would be very cool to have a singleton subflow, because it is much more flexible in terms on input parameters and multiple outputs. Allocating the "library" code outside of flows is also a plus.

---

<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:** [17 October 2025 11:45 UTC](https://discourse.nodered.org/t/best-practice-mssql-node/99386/11 "2025-10-17T11:45:24Z")

</div>

If you insist on a subflow, then in these situations, it is advisable to specify a `config` as an input and pass in the config.

There is another option - that is to move the config outside of the subflow but it is relatively unknown and not as portable.
