In Microsoft SQL Server Managment Studio, a large query returns all samples. How to do that after Command.Execute to get all selected tables programmatically. Those.

 create PROCEDURE [dbo].p1 begin select 1 select 2,3 -- выборка end /*results: 1 2 3*/ 

What would give two tables and not one. Yes, the request can be "divided" into two, but as long as there is no connection between them through local variables. Of course, you can also transfer them, but Studio catches two or three tables from the stored procedure being executed.

1) I tried OleDb - I could not get additional cursors there. I think that support for multiple tables is embedded in sqlncli.dll. 2) Perhaps somehow you can use sql tools to make such a selection, so that the tables would be folded into a table (cursor field), or for example using sp_msforeachtable.

  • Working C ++ example, unfortunately, for the time being there is no, how to reach hands - I will write. The answer + comment to the answer is enough to understand how to write it. If there is a good other answer, hello. And I already have links to reference information. Even there are two ways: one ADO and another oledb, I think oledb should work better. - nick_n_a

1 answer 1

Try working with the ADO Recordset object for C ++ .


Example of working with Recordset in VBA:

  Dim rsTree As ADODB.Recordset Dim rsTreeGrp As ADODB.Recordset Dim rsGrp As ADODB.Recordset Set rsTree = ExecuteRS("usp_pct_CatList", 2, 0, "") Set rsTreeGrp = rsTree.NextRecordset() Set rsGrp = rsTreeGrp.NextRecordset() 

The usp_pct_CatList procedure returns three samples.

  • one
    Yes, exactly, in c # this is IDataReader.NextResult . NextResult - nick_n_a
  • For c ++, here is the answer through OleDB IMultiplyResults experts-exchange.com/questions/22410744/… , ADO comes out add-in over OleDB. - nick_n_a