number of rows of a recordset | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

number of rows of a recordset

hi ho! well. i have another problem…
an user defined function (let’s call it MYFUNC) returns a table. the number of results varies between a few and a few thousands. therfore (in my script) i want split up the recordset in numerous pages. and that’s where my problem lies:
how can i retrieve the recordset AND the number of rows (with one query)? i know, i could use count first. but this doubles the execution-time. nasty…
and i do not want to loop through the recordset first… any suggestions ? peace,
sdiwi. [EDIT]
i use mssql and (not my choice…) ASP.
declare @NumberOfRows int
Select form dbo.tableFunction(…)
set @NumberOfRows = @@rowCount
Is it what you are looking for?
select name,id,tmp.cnt from sysobjects,(select count(*) cnt from sysobjects)tmp else
you need to fire second query and check for @@rowcount as told my mirco.
thanks the two of you.<br /><br />you really helped me out <img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />.<br />both ways work for me fine. <br />thx again.<br /><br />peace,<br />sdiwi.