How do I dynamicaly create an SSRS Report?

后端 未结 3 1539
闹比i
闹比i 2021-01-26 23:01

Im trying to create a report in SSRS. The report calls a stored procedure for its data. I want to display the data in a table. But the thing is, the result from the stored proc

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-26 23:21

    One solution might be to modify your SP so that the data returned looks something like:

    ColNameA       DataA       ColNameB    DataB
    AccountNumber, 1234567890, CustomerID, 948477586
    AccountNumber, 5466584426, CustomerID, 458852244
    

    Then, in SSRS drag out a table. Create a group on ColNameA. In that Group Row, place the Field ColNameA in the first Column, place ColNameB in the second column.

    In the Details Row, place DataA in the first column, and DataB in the second column, and should look like this:

    alt text

    The sample query i used was:

    select 'AccountNumber' as ColNameA, 1234567890 as DataA, 'CustomerID' as ColNameB, 0987654321 as DataB UNION 
    select 'AccountNumber' as ColNameA, 5546488393 as DataA, 'CustomerID' as ColNameB, 4747599393 as DataB
    

    Getting the names of the Columns (AccountNumber, CustomerID or CustomerName, CustomerAddress) will be the key. You can get them via:

    select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'my_table_name'
    

提交回复
热议问题