Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RowCount?

Status
Not open for further replies.

LesStockton

Programmer
Mar 29, 2005
20
US
I'm going through a simple database table doing a
Select * from tablename order by blah
I'd like to get the total number of rows and also be able to tell what record I'm on as I go through it, so that I can show a percentage complete message as progressing.
How do I get the current position within the record set, and the total number of records so that I can make this calculation?
I figure I can count as I go and get current row, but I still need total rows.
 
I beleive your table would need to have an identity seed value that you could use to know what record you are on. Then in your select statement you would need to leverage the MAX(IdentitySeedColumn) to know how many records you have returned.

Now w/ SQL you are going to get the FULL record set returned. unless you use a looping command like a while or a cursor, you are not going to be able to use a progress meter.

Pleas explain further what it is you are trying to accomplish.

Thanks

J. Kusch
 
Server-side: you can use @@ROWCOUNT immediately after SELECT query. Or perform SELECT COUNT(*) FROM tablename.

Client-side: check recordset properties, there must be recordCount or something. This has some other pre-requirements though (cursor location/type).

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Select * From ImageRecords Where DateModified >= '" & StartingAt & "' AND DateModified <= "
"'" & EndingAt & "' ORDER BY RecId "

Ok. That's my statement that I'm building within VB6.
How do I get a row count with this?
 
Select count(*) as rowCnt From ImageRecords Where DateModified >= '" & StartingAt & "' AND DateModified <= "'" & EndingAt & "'"

Or you can use RS.recordCount property on first recordset (SELECT *), assuming that cursorType and cursorLocation are properly set.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top