繁体   English   中英

SSRS中的动态SQL查询(Sql Server Report Server 2012)

[英]Dynamic sql query in SSRS (Sql Server Report Server 2012)

我在vs2010中创建了一个名为“ clients ”的报告,其中显示了具有以下属性的客户端列表:

clientID,firstname,lastname,adres,country,birthday

我用数据源和数据集创建了这个报告。 在这个数据集中,我创建了一个这样的查询:

select firstname, lastname, adres, country, birthday
from clients

这很有效!

我想添加2 optonal parameters

param_clientID ,param_birthDay

如果填充,我想在where clausule中使用这些参数。

where clientID = param_clientID and birthday = param_birthDay

应该可以填充clientID,而不是生日参数。 否则也。

我怎样才能做到这一点?

向您报告添加(可选)参数非常简单。

首先使您的参数可以为空。

select firstname, lastname, adres, country, birthday 
from clients
where (clientID = @clientID or @clientID is null) 
and (birthday = @birthDay or @birthDay is null)

有关更详细的说明:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM