Dynamic query in SSRS for Dynamic Reports

Hi all,
I have a scenario to create a Dynamic report using a query nor a stored proc due to performance issues. I am half way done through it. I am ready with the Dynamic query but i am not able to figure out how can create a report in SSRS using this query. I tried copy pasting my dynamic query in the Text part of the wizard but i dont think thats the right way to do... I am also attaching my dynamic Query here. Please help...


Use AdventureWorks
DECLARE @SQLString nvarchar(4000),
                        @GroupByString nvarchar(4000),
                        @OrderByString nvarchar(4000),
                        @ParamList nvarchar(4000),
                        @EmployeeID1 varchar(20),
                        @ContactID1 varchar(20),
                        @EmployeeID int,
                        @BEGIN varchar(12),
                        @END varchar(12),
                        @ContactID int,
                        @COLUMN_LIST varchar(4000),
                        @Order_By varchar(4000)
                        

--select          @EmployeeID = 100963,    
--                        @BEGIN ='07/31/1996',
--                        @END ='07/01/2003',
--                        @ContactID = null,
--                        @COLUMN_LIST = 'EmployeeID,Title,Gender,VacationHours,BirthDate',
--                        @Order_By = 'BirthDate,Gender'


set @SQLString = 'Select top 10 '
set @GroupByString = ' Group By '
set @OrderByString = ' Order By '
set @EmployeeID1 = convert(varchar, @EmployeeID)
set @ContactID1 = convert(varchar, @ContactID)

set @SQLString = @SQLString +       @COLUMN_LIST
set @SQLString = @SQLString +       ' from Humanresources.Employee '
set @SQLString = @SQLString +       ' where 1 = 1'

if (@BEGIN is not null and @END is not null)
set @SQLString = @SQLString +       ' and HireDate BETWEEN ''' + convert(nvarchar(20), @Begin) + ''' AND '''  + convert(nvarchar(20), @End) + ''''


if (@ContactID is not null)
set @SQLString = @SQLString +       ' and ContactID = ' + @ContactID1

if (@Order_By is not null)
set @SQLString = @SQLString + @OrderByString + @Order_By

--print @SQLString
exec(@SqlString)


vredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

planoczCommented:
Are you using 2005 or 2008?
0
EmesCommented:
Are you using a table or Matrix?

are you going to have a constant number of columns returned?
0
vredAuthor Commented:
NO solution Found
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.