# How to call a stored procedure in a named query MSSQL

**URL:** <https://forum.inductiveautomation.com/t/how-to-call-a-stored-procedure-in-a-named-query-mssql/47844>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [June 16, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/how-to-call-a-stored-procedure-in-a-named-query-mssql/47844 "2021-06-16T16:44:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [June 16, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/how-to-call-a-stored-procedure-in-a-named-query-mssql/47844/1 "2021-06-16T16:44:18Z")

</div>

I have a stored procedure with one string parameter. I have tried the following:

exec mySproc :s – results in “incorrect syntax near ‘:’  
exec mySproc @s = :s – results in “incorrect syntax near ‘:’  
exec mySproc ‘:s’ – successfully calls the sproc but the parameter value it delivers is literally ':s”, NOT the parameter value I am sending in from the named query testing tab.  
exec mySproc @s = ‘:s’ – successfully calls the sproc but the parameter value it delivers is literally ':s”, NOT the parameter value I am sending in from the named query testing tab.

I can’t think of any other way to create a named query using a stored procedure. Has anyone done this?

---

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [June 16, 2021, 5:18pm UTC](https://forum.inductiveautomation.com/t/how-to-call-a-stored-procedure-in-a-named-query-mssql/47844/2 "2021-06-16T17:18:53Z")

</div>

it was an issue of ignition not having saved the parameter name. I had overwritten the name of one of the default parameters, and the change hadn’t ‘stuck’. Also, simply typing in the parameter name in the query/sproc seems not to work. You should right click, insert paramter.

---

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [February 12, 2024, 9:17pm UTC](https://forum.inductiveautomation.com/t/how-to-call-a-stored-procedure-in-a-named-query-mssql/47844/3 "2024-02-12T21:17:03Z")

</div>

In case that someone need a sample  
MSSQL server, stored procedure called from Named Query with parameters

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/82d3174f48954fd9247e9ac1963ff0d781e61c9f.png)
