How many records does a query return?

How many records does a query return?


I need to show the number of records in a List. The list only shows 15 records, so the query that feeds it uses a limit , so that it only returns the required records. However, I need to know the number of records it would return if there wasn't a limit.

Suppose there are 1000 records that satisfy the query conditions. Because I'm using a limit, I only get the first 15, then the first 30, and so on. How can I know that there are in fact 1000 records?

Is there any way to do that other than using an advanced query?

You have to options:
1 - Use another advanced query (select count(*) from...) that outputs to a structure with an integer and use it's value.
For scalabillity reasons this is the best aproach

2 - Increase Max. Records property to a value that you now that will always be larger than the returned row count (Max. Records will be an optional parameter in a future release). A coherence suggestion warning will be issued that you should ignore. You can then use Query.ReturnedRowCount to know the number of records.


I had already figuered it out, option 1 also seemed to be the better to me. However I was hoping I could access the @@rowcount from SQL Server...

Oh well! :)

Is there a way, in ServiceStudio 3.0, to "tell" the query that I want all the records, independently of their number, or the explination below still applies to this version?


Gonçalo Almeida
Hi Gonçalo,

In version 3.0 the property “Max. Records” is still mandatory in Simple Query nodes, meaning that you still have to follow Tiago’s earlier suggestion and supply it with a “large enough” number so that your query results are not capped. I can, however, confirm that the change to this property has not been dropped and will occur in a future version of the product.

As a side note, the upcoming Hub Edition version 3.1.2 includes new query-related features (for both Advanced and Simple Queries) which will greatly simplify the development cycle. More information will be given closer to the release date.

Best regards,

Thanks for the quick answer Miguel.