# MSSQL Stored procedure

**URL:** <https://discourse.nodered.org/t/mssql-stored-procedure/53382>\
**Category:** Developing Nodes\
**Tags:** database\
**Created:** [8 November 2021 14:19 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382 "2021-11-08T14:19:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![egoncalves](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@egoncalves](https://discourse.nodered.org/u/egoncalves)\
**Post date:** [8 November 2021 14:19 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/1 "2021-11-08T14:19:04Z")

</div>

Hey guys,  
how to execute a stored procedure and store the result to use in another query?

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [8 November 2021 16:44 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/2 "2021-11-08T16:44:47Z")

</div>

Welkom to the forum

Search INSERT the data into the database, there is a node for MYSQL aswell

---

<div class="post-metadata">

**Author:** ![grant1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/grant1/32/49890_2.png) [@grant1](https://discourse.nodered.org/u/grant1)\
**Post date:** [9 November 2021 01:53 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/3 "2021-11-09T01:53:19Z")

</div>

Welcome @egoncalves

[This thread](https://discourse.nodered.org/t/stored-procedure-with-mssql-plus-node/36466) about how to execute a stored procedure in MSSQL should help. Obviously your inputs & outputs are different, but this should get you going.

---

<div class="post-metadata">

**Author:** ![egoncalves](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@egoncalves](https://discourse.nodered.org/u/egoncalves)\
**Post date:** [10 November 2021 19:27 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/4 "2021-11-10T19:27:44Z")

</div>

Thanks for your attention, I don't think I was able to express myself properly, I would like to run this example query, and get a return value from the entire execution like this example.

declare @ReturnID int

execute @ReturnID = [dbo].[LogN2\_Event] 1,1 ,1

print 'Return value = ' + cast (@ReturnID as varchar (10) )

Return value = 1053658

Completion time: 2021-11-10T16:30:07.1955275-03:00

After the procedure runs, it returns a value that I store in the @ReturnID variable

---

<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:** [10 November 2021 20:04 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/5 "2021-11-10T20:04:06Z")

</div>

Please wrap your code in code tags ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2868fdaff6757ecbb8b2dac2b6ad16acbda61cf8.png)  
so that it is readable thanks.

---

<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 January 2022 20:04 UTC](https://discourse.nodered.org/t/mssql-stored-procedure/53382/6 "2022-01-09T20:04:36Z")

</div>

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