# SQL Server stored procs w/multiple result sets?

**URL:** <https://www.ruby-forum.com/t/sql-server-stored-procs-w-multiple-result-sets/91497>\
**Category:** Rails\
**Created:** [April 9, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/sql-server-stored-procs-w-multiple-result-sets/91497 "2007-04-09T21:20:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 9, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/sql-server-stored-procs-w-multiple-result-sets/91497/1 "2007-04-09T21:20:32Z")

</div>

All,

I have a legacy database that I’m dealing with and a stored procedure  
that I need to call.

I found this and it’s great for calling a SP that returns only one  
result set -

> **[SQL Server Stored Procedures and Rails](http://made-of-stone.blogspot.com/2006/01/sql-server-stored-procedures-and-rails.html)**
>
> DHH says "it's not the Rails way" but I needed to access our application's stored procedures, so I wrote a module to do it. This code is Co...

However, this SP returns several result sets (4) and I need data from  
the 2nd and 3rd result sets.

Does anyone know how I would need to enhance the referenced code above  
to handle multiple result sets returned from the SP?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 13, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/sql-server-stored-procs-w-multiple-result-sets/91497/2 "2007-04-13T17:59:59Z")

</div>

Wes G. wrote:

> Does anyone know how I would need to enhance the referenced code above  
> to handle multiple result sets returned from the SP?

Hi  
I wrote the SP code you linked to. I have been meaning to rewrite it  
using ADO directly - the Win32OLE stuff built into Ruby lets you create  
COM objects (such as an ADOCommand) and call it directly. In other  
words forget the “construct a big string” approach and bypass  
ActiveRecord’s connection entirely. Unfortunately, I’ve never had time  
to do it and I’m not really working with Sql Server at the moment. But  
that would be the way to go.

Baz.
