[英]alternative way to TRIM for SSRS (not Crystal Reports)
I imported a report from Crystal to SSRS. 我将报表从Crystal导入到SSRS。
When I run the query in Microsoft Management Console, it throws errors unless I declare variables before the SELECT statement. 在Microsoft管理控制台中运行查询时,除非我在SELECT语句之前声明变量,否则它将引发错误。 When I run the query from Visual Studio, it bypasses these variables and only throws an error on the TRIM function.
当我从Visual Studio运行查询时,它会绕过这些变量,只会在TRIM函数上引发错误。
From what I can tell a JOIN statement may be used instead of a TRIM, but I am not sure. 据我所知,可以使用JOIN语句代替TRIM,但是我不确定。
This is the portion of a where clause that I am trying to change/adapt to work with SSRS, which is throwing an error -- any suggestions appreciated. 这是我试图更改/适应与SSRS一起使用的where子句的一部分,它引发了错误-任何建议都值得赞赏。
Also, I am having issues with the DateSerial in the WHERE clause as follows: 另外,我在WHERE子句中遇到DateSerial的问题,如下所示:
AND (CAST(@StartDate AS Date) <> DateSerial(1900, 01, 01)) AND AND(CAST(@StartDate AS Date)<> DateSerial(1900,01,01))AND
Trim does not work in SQL only in the report expressions you would have to use LTrim and RTrim to make this work. 修剪仅在报表表达式中不能在SQL中工作,您必须使用LTrim和RTrim才能使此工作正常进行。
AND ( ( NOT ( @Status IS NULL )
AND RTrim(LTrim(@Status)) <> 'All' )
(( ( RTrim(Ltrim(@Status)) = 'Completed' )
AND RTrim(LTrim(@AssignedTo)) <> 'All' )
AND ( submission.assignedto IN ( @AssignedTo ) )
INCLUDING THE ENTIRE WHERE CLAUSE: 包括整个条款:
WHERE ( @ParameterIds IS NOT NULL or ParameterIds = @ParameterIds )
AND @ParameterIds <> 0 )
AND ( requested_table.parameterid IN ( @ParameterIds ) ) )
AND requested_table.columnname = 'INSERT'
AND ( ( NOT ( @Parameter2 IS NULL )
AND Trim(@Parameter2) <> 'All' )
AND (( ( Trim(@Parameter2) = 'Completed' )
AND (( requested_table.columnname = 'Dup'
OR requested_table.columnname = 'IDup'
OR requested_table.columnname = 'W/D'
OR requested_table.columnname = 'Done'
OR requested_table.columnname = 'QA Review Dup'
OR requested_table.columnname = 'X' ))
OR ( requested_table.columnname IN ( @Parameter2 ) ) )) )
AND ( ( @ParameterIds = 0 )
AND ( ( ( NOT ( @StartDate IS NULL )
AND ( Cast (@StartDate AS DATE) <>
Dateserial(1900, 01, 01) ) )
AND ( submission.dateimported >= Datevalue (@StartDate) ) )
AND ( ( NOT ( @EndDate IS NULL )
AND ( Cast (@EndDate AS DATE) <>
Dateserial(1900, 01, 01) )
)
AND ( table.dateimported <= Datevalue (@EndDate) )
) ) )
AND ( ( @ParameterIds = 0 )
AND (( ( NOT ( @Parameter5 IS NULL )
AND Trim(@Parameter5) <> 'All' )
AND ( table.assignedto IN ( @Parameter5 ) ) )) )
Fix the Dateserial and this should work. 修复Dateserial,这应该可以工作。
WHERE ( @ParameterIds IS NOT NULL or ParameterIds = @ParameterIds )
AND (@ParameterIds <> 0 )
AND ( requested_table.parameterid IN ( @ParameterIds ) )
AND requested_table.columnname = 'INSERT'
AND ( ( (@Parameter2 IS NOT NULL )
AND LTRIM(RTrim(@Parameter2)) <> 'All' )
AND (( ( LTRIM(RTrim((@Parameter2)) = 'Completed' )
AND (( requested_table.columnname = 'Dup'
OR requested_table.columnname = 'IDup'
OR requested_table.columnname = 'W/D'
OR requested_table.columnname = 'Done'
OR requested_table.columnname = 'QA Review Dup'
OR requested_table.columnname = 'X' ))
OR ( requested_table.columnname IN ( @Parameter2 ) ) )) )
AND ( ( @ParameterIds = 0 )
AND ( ( ( ( @StartDate IS NOT NULL )
AND ( Cast (@StartDate AS DATE) <>
Dateserial(1900, 01, 01) ) )
AND ( submission.dateimported >= (@StartDate) ) )
AND ( ( ( @EndDate IS NOT NULL )
AND ( Cast (@EndDate AS DATE) <>
Dateserial(1900, 01, 01) )
)
AND ( table.dateimported <= (@EndDate) )
) ) )
AND ( ( @ParameterIds = 0 )
AND (( ( ( @Parameter5 IS NOT NULL )
AND RTRIM(LTrim(@Parameter5)) <> 'All' )
AND ( table.assignedto IN ( @Parameter5 ) ) )) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.