SQL Server 2005,Pagin Query获取所有结果计数

时间:2020-12-05 23:33:03

HI,

I have some Tables with a lot of records , for a report I have to join these tables.

我有一些包含大量记录的表,对于我必须加入这些表的报告。

If I want to get all rows I get the Time out error, I used Paging query in SQL Server 2005 , and can get the result page by page.

如果我想得到所有行,我得到Time out错误,我在SQL Server 2005中使用了Paging查询,并且可以逐页获取结果。

but I need to know the count of results or the count of pages of my query. on a paged query , if I use count() I got the page size , not the all result count, and if I try to get count() on all records also I get Timeout error message.

但我需要知道结果的数量或查询的页数。在分页查询中,如果我使用count()我得到页面大小,而不是所有结果计数,如果我尝试在所有记录上获取count(),我也会收到Timeout错误消息。

Is there any method that can help to find the page counts of a query?

有没有什么方法可以帮助查找查询的页数?

Thanks

1 个解决方案

#1


Normally page-aware select stored procedures (created by for instance .netTiers CodeSmith template) return a multiple result. The first result set is one page of data and the second set is number of records.

通常,页面感知选择存储过程(例如由.netTiers CodeSmith模板创建)返回多个结果。第一个结果集是一页数据,第二个结果是记录数。

It means you must have two SELECT statements in your SP that both have the same WHERE clause that applies the same filter over the rows of the query.

这意味着您的SP中必须有两个SELECT语句,它们都具有相同的WHERE子句,该子句在查询的行上应用相同的过滤器。

#1


Normally page-aware select stored procedures (created by for instance .netTiers CodeSmith template) return a multiple result. The first result set is one page of data and the second set is number of records.

通常,页面感知选择存储过程(例如由.netTiers CodeSmith模板创建)返回多个结果。第一个结果集是一页数据,第二个结果是记录数。

It means you must have two SELECT statements in your SP that both have the same WHERE clause that applies the same filter over the rows of the query.

这意味着您的SP中必须有两个SELECT语句,它们都具有相同的WHERE子句,该子句在查询的行上应用相同的过滤器。