当您可以在 SSRS 中选择多个数据源时,我不明白您为什么要执行 Openquery。
我会做一些比这更简单的事情。
- 为您的表格日期设置一个数据源,如果您的实际数据在其他地方,则设置另一个数据源。
设置一个数据集,将其称为“MaxDate”,用于最后一个日期,例如:
Select Max(Date) as MaxDate
From (tableName)
这为您提供了听起来像您想要的整个表格的最大日期。
在 2 中设置获取此数据集的参数。通过选择参数以使用“从查询中获取值”。选择它以使用 MaxDate 作为 id 和标签。
现在为您的主查询设置一个数据集,但是您喜欢并执行如下谓词:
Where dt between @Start and @MaxDate
You can set up the @Start parameter with whatever you want for the date values but the @MaxDate is bound to a max date you specified.
** Optional: You set another Date field as @End and just default the value of the @MaxDate to it if you want the flexibility to not HAVE TO use the @MaxDate. You would simply create a third variable, @End, and then in the 'Default Values' pane choose 'specify values'. Hit the 'Fx' (expression) button, and then choose Parameters!MaxDate.Value and this would DEFAULT it to the max date. But you could choose a prior date as well.
I usually set up most of my reports up with defaults for dates from a shared dataset to keep them all running on set date ranges.