# Is it possible to use only a single database node like (mssql) to run sequential queries in node-red?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949>\
**Category:** General\
**Created:** [26 August 2022 08:05 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949 "2022-08-26T08:05:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirajan](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@Nirajan](https://discourse.nodered.org/u/Nirajan)\
**Post date:** [26 August 2022 08:05 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/1 "2022-08-26T08:05:25Z")

</div>

Hi Everyone,

I need to an insert query to store a record on MS SQL Server. Once the insert query is successful, i need to run a select query to another table, based on the id (Primary key) of the newly inserted record from the first query.

It seems that i need use two mssql nodes for this purpose. And if i have to execute more queries sequentially, then i need to keep on adding new more mssql nodes.

 ![node-red-forum-image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/25eae4d698130ff940c8c1a36174471d337564f3.png)

Is there any way to only use a single mssql node and run different types of queries one after another? I would be really glad if anyone could help me to clear my confusions or misunderstandings.

Thanks in advance.

Best Regards,

---

<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:** [26 August 2022 08:23 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/2 "2022-08-26T08:23:13Z")

</div>

Firstly, that node is pretty much abandond (and has known issues) - you should remove it an use the node-red-contrib-mssql-plus node.

So in the query, you can do things like this...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/55a49e65804c0913d74a92fccf17d820cfd31410.png)

* * *

All that said - what is the harm in multiple nodes?

- They use a config so there is a shared (pooled) connection
- They give you a graphical means of understanding the flow (i.e. low code)

I suspect the functions you wrote could also be replaced with the low code nodes like `switch` and `change`

---

<div class="post-metadata">

**Author:** ![Nirajan](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@Nirajan](https://discourse.nodered.org/u/Nirajan)\
**Post date:** [26 August 2022 08:46 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/3 "2022-08-26T08:46:11Z")

</div>

Hello Steve,

First of all, thank you very much for the detailed explanation and also for guiding me to use node-red-contrib-mssql-plus in an efficient way. This is very helpful.

And yes there is infact no any harm in using multiple nodes. If it could be controlled, i just wanted to avoid occupying more flow area while defining nodes with same configuration.

But i have a better understanding now. Thank you very much.

Best Regards,  
Nirajan

---

<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:** [26 August 2022 08:56 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/4 "2022-08-26T08:56:09Z")

</div>

> [@Nirajan](#):
>
> i just wanted to avoid occupying more flow area while defining nodes with same configuration

Well, the config is set once & shared across all MSSQL-PLUS nodes.

However, if you mean you have same query and input parameters and want to re-use it, then the `link call` --\> `link in` --\> `MSSQL` --\> `link out (return mode)` node is perfect for that...

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

---

<div class="post-metadata">

**Author:** ![Nirajan](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@Nirajan](https://discourse.nodered.org/u/Nirajan)\
**Post date:** [26 August 2022 09:32 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/5 "2022-08-26T09:32:25Z")

</div>

Hello Steve,

I will have a look at it as well. Thank you very much for the information.

Best regards,  
Nirajan

---

<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:** [26 August 2022 11:53 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/6 "2022-08-26T11:53:51Z")

</div>

Sorry, didn't maybe read your question very well but couldn't you simply do a combined SQL command with 2 statements. 1 to do the update and the 2nd to do the query? Does the SQL+ node allow that?

---

<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:** [26 August 2022 11:59 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/7 "2022-08-26T11:59:01Z")

</div>

> [@TotallyInformation](#):
>
> couldn't you simply do a combined SQL command with 2 statements. 1 to do the update and the 2nd to do the query? Does the SQL+ node allow that

👇urm 👇 ...

> [@Steve-Mcl](#):
>
> you can do things like this...
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/55a49e65804c0913d74a92fccf17d820cfd31410.png)

😃

---

<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:** [26 August 2022 12:00 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/8 "2022-08-26T12:00:25Z")

</div>

Ah, there you go then! Told you I probably hadn't read it properly! (Goofing around over lunch on a Friday afternoon - never really a good idea!).

---

<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:** [9 September 2022 12:01 UTC](https://discourse.nodered.org/t/is-it-possible-to-use-only-a-single-database-node-like-mssql-to-run-sequential-queries-in-node-red/66949/9 "2022-09-09T12:01:19Z")

</div>

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