# Using Stored Procedure In Reporting

**URL:** <https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553>\
**Category:** Ignition\
**Created:** [January 10, 2018, 9:09pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553 "2018-01-10T21:09:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt.wright](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@matt.wright](https://forum.inductiveautomation.com/u/matt.wright)\
**Post date:** [January 10, 2018, 9:09pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/1 "2018-01-10T21:09:33Z")

</div>

I am currently utilizing some stored procedures to populate tables within the Ignition Designer.

I want to utilize the result sets in a table and pie object in the Report Viewer but it looks to me like the Script option data source does not support this in the function that’s provided.

How would I go about returning a data set from SQL Server into the Report Viewer?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 10, 2018, 9:13pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/2 "2018-01-10T21:13:08Z")

</div>

You can just put the name of a stored procedure inside the Basic SQL Query datasource type.  
I just tested it with a single parameter SP.

NameOfMyStoredProcedure MyParameter

---

<div class="post-metadata">

**Author:** ![matt.wright](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@matt.wright](https://forum.inductiveautomation.com/u/matt.wright)\
**Post date:** [January 10, 2018, 9:15pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/3 "2018-01-10T21:15:38Z")

</div>

What does the syntax look like? I had been using something like this:

call = system.db.createSProcCall(“sproc”)  
call.registerInParam(“p1”, system.db.TIMESTAMP, var1)  
call.registerInParam(“p2”, system.db.TIMESTAMP, var2)  
system.db.execSProcCall(call)

data = call.getResultSet()

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 10, 2018, 9:18pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/4 "2018-01-10T21:18:55Z")

</div>

Literally MyStoredProcedureName ‘MyStringParameter’

---

<div class="post-metadata">

**Author:** ![matt.wright](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@matt.wright](https://forum.inductiveautomation.com/u/matt.wright)\
**Post date:** [January 10, 2018, 9:23pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/5 "2018-01-10T21:23:54Z")

</div>

It works - so simple it went right over my head

---

<div class="post-metadata">

**Author:** ![SergioS](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@SergioS](https://forum.inductiveautomation.com/u/SergioS)\
**Post date:** [December 13, 2018, 5:02pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/6 "2018-12-13T17:02:58Z")

</div>

Good morning,  
if I have more parameters for store procedure, how can I send them?

I’m try to do in this mode :

spReportAnalisiFermate {pDateStart} {pDateEnd} {pGplant\_AS} {pMachine\_AS} {plang} {pCod\_MacroStp\_AS} {pZone\_Prod\_AS}

---

<div class="post-metadata">

**Author:** ![SergioS](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@SergioS](https://forum.inductiveautomation.com/u/SergioS)\
**Post date:** [December 13, 2018, 6:01pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/7 "2018-12-13T18:01:05Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e9ee687f6e80d20b659fcfac1c7f5863f0ecb30c.png)

in this mode only errors

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [December 13, 2018, 6:03pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/8 "2018-12-13T18:03:19Z")

</div>

Separate them with commas

`spReportAnalisiFermate {pDateStart},{pDateEnd},{pGplant_AS},{pMachine_AS},{plang},{pCod_MacroStp_AS},{pZone_Prod_AS}`

---

<div class="post-metadata">

**Author:** ![SergioS](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@SergioS](https://forum.inductiveautomation.com/u/SergioS)\
**Post date:** [December 13, 2018, 6:35pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/9 "2018-12-13T18:35:53Z")

</div>

> [@MMaynard](#):
>
> spReportAnalisiFermate {pDateStart},{pDateEnd},{pGplant\_AS},{pMachine\_AS},{plang},{pCod\_MacroStp\_AS},{pZone\_Prod\_AS}

i get this error...

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/68e7acc97f35ff2e40d78c56ad1ebe5e179282bc.png)

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [December 13, 2018, 6:57pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/10 "2018-12-13T18:57:51Z")

</div>

Change your Query Type to Basic SQL Query

---

<div class="post-metadata">

**Author:** ![SergioS](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@SergioS](https://forum.inductiveautomation.com/u/SergioS)\
**Post date:** [December 14, 2018, 7:29am UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/11 "2018-12-14T07:29:39Z")

</div>

I have try to put Basic SQL Query, now error is go away but a new error is on.

How i can debug these?

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [December 14, 2018, 3:04pm UTC](https://forum.inductiveautomation.com/t/using-stored-procedure-in-reporting/16553/12 "2018-12-14T15:04:57Z")

</div>

Post the new error and a screenshot of your report data tab
