Sql server 添加where子句后SSRS SQL查询显示错误

Sql server 添加where子句后SSRS SQL查询显示错误,sql-server,reporting-services,Sql Server,Reporting Services,我有一个可以在SSRS中正确显示的完整查询,但是,当我添加这个where子句时,我得到一个错误 数据集“dataset1”的查询执行失败。(rsErrorExecutingCommand) 这是我添加的其中条款: where (itemNo = @ItemNo or @ItemNo is NULL) and (JobNo in (@JobNo) or @JobNo is NULL) and (customerNo = @CustomerNo or @Customer

我有一个可以在SSRS中正确显示的完整查询,但是,当我添加这个
where
子句时,我得到一个错误

数据集“dataset1”的查询执行失败。(rsErrorExecutingCommand)

这是我添加的
其中
条款:

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))

你们知道我在这里犯的语法错误是什么吗?

添加字符串后,我的代码正常工作。下面是我所做的,它的工作很好。 这是因为,我注意到值不是Null,而是一个空字符串,这就是我的代码不工作的原因

(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))

可能原始查询已经有了一个
where
子句?不..这是唯一的where。我确实怀疑“in”给我带来了麻烦,因为记录中可能有空值。括号是平衡的。我可以想象逻辑是错误的。然而,唯一的语法问题(我认为)是某个地方的类型不兼容。你能解释一下“不兼容”吗?如果一列是一种类型(比如说整数),而一个变量是另一种类型(比如varchar),那么当转换失败时,比较可能会因为类型不兼容而失败。