简体   繁体   中英

SSRS SQL Query display error after i add where clause

I have a full query which can be display correctly in SSRS, however, when I add this where clause, I get an error

Query execution failed for data set 'dataset1'. (rsErrorExecutingCommand)

This is the WHERE clause I add:

where 
    (itemNo = @ItemNo or @ItemNo is NULL) 
    and (JobNo in (@JobNo) or @JobNo is NULL) 
    and (customerNo = @CustomerNo or @CustomerNo is NULL) 
    and (LotNo in (@LotNo) or @LotNo is NULL)
    and (Station = @Station or @Station is NULL) 
    and ((DateTimeStamp between @startDate and  @endDate) or (@startDate is null and @endDate is Null))

Do you guys have any idea what is the syntax error I did here?

My codes is working after i add the String. below is what i did, and its working fine. This is because,instead of Null, i notice the value is not Null, its a empty string,that is why my codes is not working.

(itemNo = @ItemNo or @ItemNo is NULL or @ItemNo = '') 
and(JobNo = @JobNo or @JobNo is NULL or @JobNo = '')
and(customerNo = @CustomerNo or @CustomerNo is NULL or @CustomerNo = '') 
and (LotNo = @LotNo or @LotNo is Null or @LotNo = '')
and (Station = @Station or @Station is NULL or Station = '') 
and ((DateTimeStamp between @startDate and @endDate) or (@startDate is null and @endDate is Null))

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