简体   繁体   中英

SSRS 2008 R2: An expression of non-boolean type specified in a context where a condition is expected, near ','

In my SSRS 2008 R2 report I have a multi-value @Status parameter. This is the dataset:

SELECT 1 AS ID, Description
FROM [ApplicationStatus]
WHERE StatusID IN (5, 6, 11, 14)
UNION
SELECT 2 AS ID, Description
FROM [ApplicationStatus]
WHERE StatusID IN (10)

In my main ReportData dataset I have the following filter:

WHERE ((@Status IN (1) AND a.StatusID IN (5, 6, 11, 14)) 
OR (@Status IN (2) AND a.StatusID IN (10)))

The report runs fine when selecting either 1 and 2 as the value in the @Status drop-down, but when I select the built-in '(Select All)' option, I get the following error message:

Query execution failed for dataset 'ReportData'. An expression of non-boolean type specified in a context where a condition is expected, near ','.

The multiple values are in @Status, therefore @status needs to be after IN, not before.

WHERE (( 1 IN (@Status)  AND a.StatusID IN (5, 6, 11, 14)) 
OR (2 In (@Status) AND a.StatusID IN (10)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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