vendredi 30 janvier 2015

Find out beforehand how many records a query has


I develop reports in ExtJS resulting of queries in SQL Server 2012.


I use Ext.Grid with paging, therefore I can use offset to limit the amount of records a query will return. But for this ExtJS feature to work, I still must provide it the total amount of records the giving query has.


Some reports use filters and data changes during day, because of that I can only know the total count by running the query. This results in running it twice: once with count(*) to get total count and again to get proper data.


Is there a way to find the total count of a query, even when it has offset command, without having to run it twice as I'm doing now, and without looping through all records?





Aucun commentaire:

Enregistrer un commentaire