菜鸟问:存储过程的问题。 set @where = ' where SL.CrtDate between '''+@BeginDate+''' and '''+@EndDate+''' and (S.name like '''+@Store+''' or '+@Store+' is null) and (SL.ListFlag = '''+@ListFlag+''' or '+@ListFlag+' is null) and (SL.ListNo like '''+@ListNo+''' or '+@ListNo+' is null) and (SL.HostNo like '''+@HostNo+''' or '+@HostNo+' is null) and (UT.username like '''+@OptName+''' or '+@OptName+' is null) and (E.Name like '''+@SalesName+''' or '+@SalesName+' is null) '
调用时老提示关键字 'is' 附近有语法错误。
------解决方案-------------------- and (S.name like '''+@Store+''' or '+@Store+' is null) and (SL.ListFlag = '''+@ListFlag+''' or '+@ListFlag+' is null) and (SL.ListNo like '''+@ListNo+''' or '+@ListNo+' is null) and (SL.HostNo like '''+@HostNo+''' or '+@HostNo+' is null) and (UT.username like '''+@OptName+''' or '+@OptName+' is null) and (E.Name like '''+@SalesName+''' or '+@SalesName+' is null)
这么多个,先只写一个试试.
把拼接生成的语句,打印到界面上,单独复制运行拼接出来语句.再找错误就好办了.
------解决方案-------------------- S.name like '''+@Store+''' or S.name is null
或许,里面应该如此.
------解决方案-------------------- "or '+@ListNo+' is null)“ ListNo是整型或者长整型吧?如果是这样,就不能在后面加上is null,因为整型或者长整型是值类型,即使没有赋值,也有个默认值0,你试试把它改成<>0吧!
------解决方案--------------------
------解决方案-------------------- and (S.name like '''+@Store+''' or '''+@Store+''' is null)
------解决方案-------------------- 用print @where 输出sql调试一下
------解决方案-------------------- 你那是双引号 还是 3个单引号?