Monday, March 19, 2012

Controlling the resultset size.

I'm using a report basically as a form. In this form I want the same number of lineitems no matter if I have 2 rows of data or 5 rows of data in my resultset. I basically want extra blank lines to roundout the resultset. The reason, is that with extra rows people printing the form can write additional data. Also, it will preseve the formatting. So I either need a way to tell a table in SSRS that it needs to have a minimum number of rows, OR, I need a way to add extra blank/null rows to a result set. Any ideas?

Hello,

I just developed a working solution to the same problem a few minutes ago. My problem was that the footer in the table was appearing in random places depending on the number of rows returned. I can fit 7 rows, so I needed to pad out additional rows to equal 7. So, I had to add additional data to the SQL resultset to do this. After my stored procedure produced a resultset, I immediately invoked this function to add more rows before returning to the report. Hope this helps. If anyone has an elegant solution, please post, I would like to implement it!

ALTER FUNCTION [dbo].[fCreateBlankTblRows]
(
@.nbrRows //my stored procedure figured out how many rows were returned and how many more were needed.
)

RETURNS
@.my_temp_tbl TABLE
(
id int,
id2 int,
xyx int
)
AS
BEGIN
Declare @.loopCount int;
set @.loopCount = 0;
WHILE (@.loopCount < @.nbrRows)
Begin
INSERT INTO @.my_temp_tbl
(id, id2, xyz)
VALUES (null,null,null);
set @.loopCount = @.loopCount + 1;
End;
RETURN
END

No comments:

Post a Comment