使用公共值表达式的SSRS错误

时间:2014-12-11 17:38:51

标签: reporting-services ssrs-2008 ssrs-2008-r2

运行SSRS报告时,我的查询中出现以下错误。当我在查询设计器中测试它并手动输入参数时,我得到的结果很好。但是当我运行它时,我收到以下错误:

"参数验证失败。无法为所有参数提供有效值。 (rsParameterError)&#34 ;.

我在查询设计器中手动输入的参数是@FilterByEventCode,@ FQN,@ DateStart,@ DateStop。

我把所有参数都放到了“刷新'甚至尝试了自动模式,但我仍然得到这个错误。

有什么想法吗?非常感谢您的帮助。

IF @FilterByEventCode IS NULL 
  BEGIN 
      SELECT * 
      FROM   dbo.Historywithqualityfilter(@FQN, '.Event Code,.Event Description' 
             , 
                    Dateadd(mi, -10, @DateStart), @DateStop, 'good', 'KLN-FTVP') 
  END 
ELSE 
  BEGIN 
      WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode = valueasstring), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp 
  END 

1 个答案:

答案 0 :(得分:0)

我必须在查询的第一部分添加cte,以便显示字段,从而防止出错。

IF @FilterByEventCode IS NULL 
  BEGIN 
     WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode is null), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp  
  END 
ELSE 
  BEGIN 
      WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode = valueasstring), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp 
  END