How to create SSRS Report Dynamically with Dynamic Schema, Dynamic Table Name and Dynamic Columns Part 59.1


Few months back, I created a post/video "How to Create SSRS Report When Number of Columns Can change Anytime in Source Object". In this post we are going to create another dynamic reports in which we will be able to

1) Choose the Schema form our Database
2) Choose Table for given schema from step 1
3) Choose column/s depending upon values of step 1 and Step 2
4) Display the data on report for our selected columns

This type of report can be very helpful when we have to simply create many details reports for users from our database. If we would like we can add also the Where clause in our report to provide filtered reports. Let's leave that challenge to you.

SQL Queries for our Data Sets

1) DS_Report 
Link to Code

3) DS_Tables
This will return the list of user tables depending upon the schema you will choose

Select Distinct Table_Name as TableName from INFORMATION_SCHEMA.TABLES
and TABLE_SCHEMA=@SchemaName
order by Table_Name

4) DS_Columns
This will return us the list of columns depending upon the selection of Schema and Table

where TABLE_SCHEMA=@SchemaName
and TABLE_NAME=@TableName

1 comment: