Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Setting a Recordset = Select Count(*) from another Recordset

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-31 : 09:10:13
Bryan writes "Is it possible to Set a Recordset = to Select from another Recordset?

It should look something like this in VB

Recordset1 = "Select Count(*) from" & Recordset2 & "Where parameters are met""

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-05-31 : 10:24:38
To my knowledge no... Would it not be easier just to select that second recordset from the table as well?

recordset1 = "Select * from table where a = 1"
recordset2 = "select * from table where a = 1 and b = 2"

Edited by - M.E. on 05/31/2002 10:28:03
Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2002-05-31 : 10:33:56
Not sure what your exact requirements are but if you are using ADO, there is a Clone method, try this:

If objRecordset.Supports(adBookmark) = True Then
Set objRecordsetClone = objRecordset.Clone(adLockReadOnly)
End If

Although, this actually creates a duplicate (pointer) recordset. Not actually a copy.

Daniel Small CEO
www.danielsmall.com

Go to Top of Page

bcollinson
Starting Member

9 Posts

Posted - 2002-05-31 : 10:53:21
take a look at the filter method of the recordset object - this may do something similar to what you're after.

Go to Top of Page

macka
Posting Yak Master

162 Posts

Posted - 2002-05-31 : 11:01:11
Do you mean something like this:

SELECT COUNT(*)
FROM (
SELECT SomeField
FROM SomeOtherTable
WHERE SomeOtherField = 1
) SomeDerivedTable
WHERE SomeDerivedTable.SomeField = 2

macka.



Edited by - macka on 05/31/2002 11:03:20
Go to Top of Page
   

- Advertisement -