[英]Generate and download report from SQL Server using SSRS with multiple parameters
I have designed a template in Report Builder and my report has 6 parameters: 我已经在Report Builder中设计了一个模板,并且我的报告具有6个参数:
Start Date, End Date, Source, Destination, Transaction, and Consignor
and my SQL table has the following columns: 并且我的SQL表具有以下列:
[DATE], [SOURCE], [DESTINATION], [REFERENCE#], [ITEMCODE], [DESCRIPTION],
[UM], [PRICE], [QTY], [AMOUNT], [MFGDATE], [EXPDATE], [LOT#], [TRANS], [CONSIGNOR], [DRDATE]
I'm having a hard time writing the expressions for the parameters and could use some help please. 我在为参数编写表达式时遇到困难,请提供一些帮助。
The query for this is fairly straight forward as it is all from a single table. 该查询非常简单,因为它们都是来自单个表。
You would write a query like the following (assuming there are no Multi Value Parameters) 您将编写类似以下的查询(假设没有多值参数)
Your main dataset will be like this: 您的主要数据集将如下所示:
Select
[DATE], [SOURCE], [DESTINATION], [REFERENCE#], [ITEMCODE], [DESCRIPTION],
[UM], [PRICE], [QTY], [AMOUNT], [MFGDATE], [EXPDATE], [LOT#], [TRANS], [CONSIGNOR], [DRDATE]
from your_table
where
your_table.Date between @start_date and @end_date
and your_table.Source = @source
and your_table.Destination= @destination
and your_table.Transaction= @transaction
and your_table.consignor= @consignor
This will create all your parameters in the report 这将在报告中创建所有参数
Now make sure for each parameter, you set the appropriate type. 现在确保为每个参数都设置了适当的类型。
IE start_date and end_date should be of type datetime etc., IE的start_date和end_date应该是datetime等类型,
You can have multiple datasets in the report that derive the parameter value for each parameter. 您可以在报表中拥有多个数据集,这些数据集可以导出每个参数的参数值。
for example.. you can have a source dataset like this 例如..您可以拥有这样的源数据集
select distinct
source
from your_table
where your_table.Date between @start_date and @end_date
Now set the source parameter dataset to point to this for value. 现在将源参数数据集设置为指向该值。
This will only return the status that are available between the selected dates.. 这只会返回所选日期之间可用的状态。
your destination dataset for the @destination parameter will be @destination参数的目标数据集将是
select distinct Destination
from your_table
where your_table.Date between @start_date and @end_date
and your_table.status = @status
Now you have to do the same for the rest of the parameters 现在您必须对其余参数执行相同的操作
Now depending on how you want to group and display.. you put a tablix and select your groupings / details etc from your main dataset. 现在,取决于您要如何分组和显示。.您放入一个tablix并从主数据集中选择分组/详细信息等。 I don't think this is the place to explain how to do that. 我认为这不是解释如何执行此操作的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.