【发布时间】:2014-11-03 00:08:58
【问题描述】:
我正在 SSRS 中编写一份报告,它需要一个搜索参数来过滤报告。该参数设置为默认允许空值,这应该让报告正常运行。
报告运行,但是在我将某些内容添加到搜索参数中之前,什么都没有返回。
是否可以使用 IIF 表达式表示如果参数为空,则正常运行报告?
这是我用来在 SSRS 中生成数据集的查询。
CREATE TABLE #StartDateTable(
stSecurityType varchar(10) NOT NULL,
stSecuritySymbol varchar(50) NOT NULL,
stPrice float NOT NULL,
stSecurityID int NOT NULL,
stPriceDate date NOT NULL
)
INSERT INTO #StartDateTable (stSecurityType, stSecuritySymbol, stPrice, stSecurityID, stPriceDate )
SELECT DISTINCT
Instruments.SecurityType, Instruments.SecuritySymbol,
InstrumentPrice.Price, InstrumentPrice.SecurityID, InstrumentPrice.PriceDate
FROM
InstrumentPrice
JOIN
Instruments ON Instruments.ID = InstrumentPrice.SecurityID
WHERE
InstrumentPrice.PriceDate = @StartDate;
CREATE TABLE #EndDateTable
(
etSecurityType varchar(10) NOT NULL,
etSecuritySymbol varchar(50) NOT NULL,
etPrice float NOT NULL,
etSecurityID int NOT NULL,
etPriceDate date NOT NULL
)
INSERT INTO #EndDateTable (etSecurityType, etSecuritySymbol, etPrice, etSecurityID, etPriceDate)
SELECT DISTINCT
Instruments.SecurityType, Instruments.SecuritySymbol,
InstrumentPrice.Price, InstrumentPrice.SecurityID,
InstrumentPrice.PriceDate
FROM
InstrumentPrice
JOIN
Instruments ON Instruments.ID = InstrumentPrice.SecurityID
WHERE
InstrumentPrice.PriceDate = @EndDate;
SELECT *
FROM #StartDateTable
LEFT JOIN #EndDateTable ON #EndDateTable.etSecurityID = #StartDateTable.stSecurityID
我使用 LIKE 将搜索参数设置为 SSRS 中数据集的过滤器,因为我希望它是通配符。
【问题讨论】:
标签: reporting-services ssrs-2008-r2