Search code examples
reporting-servicesservicereportingssrs-tablix

Reporting Services Table Duplicate Pages


I am having some issues with Reporting Services. I am building a report and I have the data from the database populating a tablix. No problem. What I need to do is because this data is used in the company and they must have duplicate paperwork so, they might need to print white, yellow, pink copy. But the data needs to be the same on each page.

I don't want to make 3 Tables for this, I just need one so I just need some sort of shortcut that states how many times to repeat the table. Like while page number is between 1 to 3 repeat this table.

I looked elsewhere for this question but all they seem to talk about is repeating the table headers, when I need table headers and detail rows.

Is this possible or am I shooting in the dark.


Solution

  • I have figured it out, it is a little like the answer above.

    In your database you can have;

    SELECT Field1,Field2 FROM YourTable
    

    a | Red

    b | Green

    c | Orange

    3 Rows would come out making 1 table in reporting services. So what you need to do is create a stored procedure like this.

    DECLARE @C INT -- THIS IS COUNTER
    DECLARE @Repeat INT -- THIS IS HOW MANY REPEATS
    DECLARE @tblTemp TABLE (GRP INT,Field1 VARCHAR(1),Field2 VARCHAR(10))
    
    SET @C = 0 -- SET COUNTER 0
    SET @Repeat = 3 -- I WANT TO REPEAT 3 TIMES AND HAVE 3 TABLES IN REPORT SERVICES.
    
    WHILE @C < @Repeat BEGIN
        SET @C += 1
        INSERT INTO @tblTemp (GRP,Field1,Field2)
        SELECT @C,Field1,Field2 FROM YourTable
    END
    
    SELECT * FROM @tblTemp
    

    Now the answer you should get is;

    1 | a | Red

    1 | b | Green

    1 | c | Orange

    2 | a | Red

    2 | b | Green

    2 | c | Orange

    3 | a | Red

    3 | b | Green

    3 | c | Orange

    All you have to do now is in reporting services select the stored procedure as data source then create your table using that data source, in the grouping section of the table selected add Parent by column name 'GRP'. Then in that Parent properties add page break on every instance of this parent. There you have it 3 tables on each page. You need more you just change the repeat number in store procedure, you could even send the repeats using a parameter.

    I used this method and it works flawlessly.