Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 How to add parameters into the view

Author  Topic 

ktech
Starting Member

7 Posts

Posted - 2014-02-10 : 13:31:15
Hi All,
I just start working on company's SSRS reports. The people who created the reports have left. Now I need to added parameters @startdate and @enddate into the report.The current report use Stored Procedure as Datasets, the sp selected from a user defined function, the function selected from a view, in the view the date are using, now it is using getdate(). How can I add parameters for users to select the dates and pass the parameters to the view?

Thanks a lot for any helps and suggestions!!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-02-10 : 13:50:14
You would do it at the stored procedure level:

create proc someproc
(@var1 int, @var2 datetime)
as
set nocount on

select column1, column2
from view1
where somecolumn1 = @var1 and somecolumn2 = @var2

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

ktech
Starting Member

7 Posts

Posted - 2014-02-10 : 20:52:39
Hi Tara,
Thank you so much for your response!!
But the dates are not used in the stored procedure, not even in the functions, they are used in the view. How can I pass the parameters through the stored procedure, function, then into the view? Or I must re-write the whole report?
Thank you!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-11 : 00:53:43
quote:
Originally posted by ktech

Hi Tara,
Thank you so much for your response!!
But the dates are not used in the stored procedure, not even in the functions, they are used in the view. How can I pass the parameters through the stored procedure, function, then into the view? Or I must re-write the whole report?
Thank you!!


you must pass parameter to stored procedure and pass it down to function when you invoke it. Then inside function use that parameter in select statement using the view to filter the data from the view based on the passed values.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

ktech
Starting Member

7 Posts

Posted - 2014-02-12 : 21:21:11
visakh16,
Thanks a lot!!
You are right, I must pass parameter to sp and function,not to view.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-13 : 08:15:58
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -