# Executing Stored Procedure From Report

**URL:** <https://forum.inductiveautomation.com/t/executing-stored-procedure-from-report/12781>\
**Category:** Ignition\
**Created:** [March 12, 2017, 8:23pm UTC](https://forum.inductiveautomation.com/t/executing-stored-procedure-from-report/12781 "2017-03-12T20:23:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadgetguru69](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@gadgetguru69](https://forum.inductiveautomation.com/u/gadgetguru69)\
**Post date:** [March 12, 2017, 8:23pm UTC](https://forum.inductiveautomation.com/t/executing-stored-procedure-from-report/12781/1 "2017-03-12T20:23:11Z")

</div>

I am looking for some way to execute a stored procedure each time a report is scheduled to run.  
Is there a way to do this from within the report itself?  
I have tired putting the command in a extra query but it just errors out.

USE [IGN\_DieselPlant]  
GO  
DECLARE @return\_value int  
EXEC @return\_value = [dbo].[usp\_fuel\_consumption]  
@report\_date = N’2017-03-01’,  
@report\_partition = N’Monthly’,  
@hour = N’1’,  
@minute = N’1’  
SELECT ‘Return Value’ = @return\_value  
GO

Also im running 7.9.1.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2017, 8:58pm UTC](https://forum.inductiveautomation.com/t/executing-stored-procedure-from-report/12781/2 "2017-03-13T20:58:13Z")

</div>

Use a scripting datasource and the [system.db.createSProcCall](https://docs.inductiveautomation.com/display/DOC79/system.db.createSProcCall) function(s). Scripting datasources will be called every time the report is run/generated, but do not have to actually return any data.
