views:

231

answers:

1

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.

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.

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

Thanks

A: 

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.

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.

Robert Koritnik
I dont use Code Smith ,if I use another select using same filter( without paging and just use count(*) , this one throw Time out
Ashian
I know you're not using CodeSmith. Otherwise you wouldn't have this problem in the first place.What's the approximate result set size (non paged)?
Robert Koritnik
check how it's done in .netTiers: http://blog.benpowell.co.uk/2009/02/paging-and-sorting-in-nettiers-custom.html
Robert Koritnik
all rows are about 450000 , and maybe for this query it return about 50000 or more
Ashian
have you used Profiler to check your SQL call?
Robert Koritnik