When creating a “grid” record with a custom subcategory, what is the best / best way to query the total number of records and also start recording using C #?
SQL to return a set of computed records:
SELECT Some, Columns, Here FROM (
SELECT ROW_NUMBER() OVER (ORDER BY Column ASC) AS RowId, *
FROM
Records
WHERE
(...)
) AS tbl
WHERE ((RowId > @Offset) AND (RowId <= (@Offset + @PageSize)) )
SQL to calculate the total number of records:
SELECT COUNT(*) FROM Records WHERE (...)
Right now I am making two trips to the server: one to get records, and the other to count the total number of records.
What is the best way (s) to combine these queries in order to avoid multiple DB outages?
source
share