Search code examples
reporting-servicesssrs-2008ssrs-2008-r2reportingservices-2005

Limit number of pages displayed in a SSRS Report


I have seen many posts regarding limiting number of rows displayed on one page in a SSRS Report. But I want to display 50 rows in one page and would like to limit the report to 5 pages. Is this possible ? Can I limit the number of pages displayed by report?


Solution

  • The Top 250 is the answer for 50 rows per page and always show five pages, what you need to also do is in your result set for your dataset, make it always return 250 rows where whatever is under 250 has a blank row.

    Here is an example:

    Create table #mytable
    (
      firstname varchar(200),
      lastname varchar(200)
    )
    
    insert into #mytable
      select 'person','lastname'
    union
    select 'person2','lastname'
    
    declare @totalrows int
    declare @blankrows int
    declare @currentrow int
    set @totalrows = count(*) from #Mytable
    
    set @blankrows = 250 - @totalrows
    set @currentrow = 1
    
    while @currentrow<=@blankrows
        begin
    
        insert into #MyTable
        SELECT
          '',
          ''
    
        end
    

    Your table should now always have 250 rows.