Commands Generating Multiple-Rowset Results

OLE DB and SQL Server

OLE DB and SQL Server

Commands Generating Multiple-Rowset Results

SQLOLEDB can return multiple rowsets from Microsoft® SQL Server™ 2000 statements. SQL Server 2000 statements return multiple-rowset results under the following conditions:

  • Batched SQL statements are submitted as a single command.

  • Stored procedures implement a batch of SQL statements.

  • SQL statements include the Transact-SQL COMPUTE or COMPUTE BY clause.
Batches

SQLOLEDB recognizes the semicolon character as a batch delimiter for SQL statements:

WCHAR*       wSQLString = L"SELECT * FROM Categories; "
                          L"SELECT * FROM Products";

Sending multiple SQL statements in one batch is more efficient than executing each SQL statement separately. Sending one batch reduces the network roundtrips from the client to the server.

Stored Procedures

SQL Server 2000 returns a result set for each statement in a stored procedure, so most SQL Server 2000 stored procedures return multiple result sets.

COMPUTE BY and COMPUTE

The Transact-SQL COMPUTE BY clause generates subtotals within a SELECT statement result set. The COMPUTE clause generates a total at the end of the result set. SQLOLEDB returns each COMPUTE BY subtotal and the COMPUTE total as a separate rowset result.