首页 > 解决方案 > SSRS 数据集可以有默认值吗?

问题描述

我的SSRS报告有一个数据集 ( datasetMacys),它调用usp_GetStoreSales @Rundate, @StoreName.

数据集可以有默认值吗?这样报告将只要求一个参数 ( @Rundate) 并且数据集嵌入了字符串值“Macys”?

换句话说,用户不必为第二个参数选择一个值,因为它已经是该数据集的默认值。

然后,我将添加第二个数据集 ( datasetSears),其中 @StoreName 的默认值为“Sears”,这意味着它只会使用@Rundate用户选择的那个。

存储过程看起来像这样,即使问题并不真正需要它:

create procedure usp_GetStoreSales 
(
    @RunDate date,
    @StoreName varchar(10)
)
as

select * from [Sales] 
where RunDate = @RunDate and StoreName = @StoreName

我可以通过创建两个不同的存储过程(即usp_GetMacysSales @RunDateusp_GetSearsSales @RunDate)轻松解决这个问题,但这正是我想要避免的。

标签: sql-servertsqlreporting-servicessql-server-2008-r2ssrs-2008

解决方案


You just need to create your two datasets and then, for each dataset, righ click the dataset name, choose properties, click the parameters tab and overwrite the parameter value for the StoreName parameter.


推荐阅读