How to merge two ADO RecordSets into one 
Author Message
 How to merge two ADO RecordSets into one

What is the best way to combine two ADO RecordSets into one ADO RecordSet?
Both ADO RecordSets have the same field names.

Thanks.

--

Peace in Christ,
Marco Napoli
http://www.*-*-*.com/



Mon, 28 Jun 2004 06:32:13 GMT  
 How to merge two ADO RecordSets into one
Assuming that the underlying database supports it, use the UNION
operator.  For example

(SELECT stuff FROM Table1) UNION (SELECT stuff FROM Table2)

would generate a single recordset.  As additional cool functionality, it
is possible to sort and group across both SELECTs by placing the ORDER
BY and GROUP BY keywords outside the UNION.

((SELECT1) UNION (SELECT2)) ORDER BY Field1

Gosh this SQL is cool sometimes. :)

Bruce Johnson
TAG Consulting

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 28 Jun 2004 09:06:07 GMT  
 How to merge two ADO RecordSets into one
Exelent, I am using SQL Server 7.0 so it should work. I will be using your
idea of putting Group By and Order By, which I needed to use.

Thank you
Marco


Quote:
> Assuming that the underlying database supports it, use the UNION
> operator.  For example

> (SELECT stuff FROM Table1) UNION (SELECT stuff FROM Table2)

> would generate a single recordset.  As additional cool functionality, it
> is possible to sort and group across both SELECTs by placing the ORDER
> BY and GROUP BY keywords outside the UNION.

> ((SELECT1) UNION (SELECT2)) ORDER BY Field1

> Gosh this SQL is cool sometimes. :)

> Bruce Johnson
> TAG Consulting

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Mon, 28 Jun 2004 13:27:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Merging Data from TWO databases into One recordset???

2. Merge two wave file one after one

3. merge two queries in one form?

4. Merging Two Word97 docs into one

5. Merge two wave file in one single wave file

6. Possible to merge two XML recordsets?

7. Recordset returns one of two specifications (?)

8. one connection for two recordset?

9. Join two recordsets into one using DAO 3.6?

10. Two Forms and One Recordset

11. Two connections, one recordset?

12. sort two different recordsets into one table

 

 
Powered by phpBB® Forum Software