# How do I get multiple records from a SQL stored procedure?

**URL:** <https://forum.inductiveautomation.com/t/how-do-i-get-multiple-records-from-a-sql-stored-procedure/76674>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 20, 2023, 6:42pm UTC](https://forum.inductiveautomation.com/t/how-do-i-get-multiple-records-from-a-sql-stored-procedure/76674 "2023-07-20T18:42:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeBr](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@MikeBr](https://forum.inductiveautomation.com/u/MikeBr)\
**Post date:** [July 20, 2023, 6:42pm UTC](https://forum.inductiveautomation.com/t/how-do-i-get-multiple-records-from-a-sql-stored-procedure/76674/1 "2023-07-20T18:42:05Z")

</div>

Hello Ignition Gurus,

Using Microsoft SQL Server and Ignition here. Works awesome except that I have run into a slight (well big) problem.....

I'm trying to get multiple records/datasets from a stored procedure but it seems like I only get the first record/dataset no matter what I do. I am using the following to execute the stored procedure (okay, I changed the names)

call = system.db.createSProcCall("Data.spMyStoredProcedure","ProductionDatabase")

then I just use this to get the result

# returns a dataset called results

results = call.getResultSet()

and then I write using something like this

system.tag.write("[default]Machine1/Dataset", results)

Problem is that I only get the first Dataset [1R x 22C] and not the subsequent records Dataset [1R x 8C], Dataset [1R x 8C], Dataset [1R x 8C], etc.

Yes, I've tried making a results, results1, results2 etc. but I can't seem to get past the first record/dataset. Help.

In the Vbscript world, I used the following

Set rs = rs.NextRecordset

and then indexed through.....is there something similar that I can do in Ignition? I've seen some similar questions in the forum so I apologize if this has been asked before.

Respectfully,  
Mike

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 20, 2023, 6:43pm UTC](https://forum.inductiveautomation.com/t/how-do-i-get-multiple-records-from-a-sql-stored-procedure/76674/2 "2023-07-20T18:43:49Z")

</div>

Not possible. I have client that suffers similarly.

I've thought of re-implementing this in a module to make it possible, but way down my to-do list.

---

<div class="post-metadata">

**Author:** ![MikeBr](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@MikeBr](https://forum.inductiveautomation.com/u/MikeBr)\
**Post date:** [July 20, 2023, 7:02pm UTC](https://forum.inductiveautomation.com/t/how-do-i-get-multiple-records-from-a-sql-stored-procedure/76674/3 "2023-07-20T19:02:13Z")

</div>

Yikes!!!! Wow, thanks Phil for your super quick response. Much, much appreciated.

Possible solution: I suppose that I can rewrite the stored procedure into multiple stored procedures, each with some key component of the dataset.....only thing that I can think of right now. So call stored procedure1 then call stored procedure2 etc.

Total bummer. I'm not a drinker but this one makes me want to cry in my beer....
