--cCellPhone<>null 
--这种判断是无效的。DECLARE @cCellPhone VARCHAR(20)
SET @cCellPhone=NULLIF(@cCellPhone=null)
SELECT '为空'
ELSE
SELECT '不等于空'
/*
不等于空
*/

解决方案 »

  1.   

    --判断为空 WHERE  col IS NULL--判断不为空WHERE  col is NOT null
      

  2.   

    select distinct cLevel
    from tb_CustomerHistory
    where 1 <> 1
    or (curl is not null and cURL = @URL)
    or (cAccount is not null and cAccount = @Account)
    or (cCompany is not null and cCompany = @Company)
    or (cCellPhone is not null and cCellPhone = @CellPhone)
    or (cEmail is not null and cEmail = @Email)
      

  3.   

    [code=SQL][select distinct(cLevel) from tb_CustomerHistory 
    where (cAccount=@Account or @Account is null) 
    and (cCompany =@Company or @Company is null)
    and  (cCellPhone=@CellPhone  or @CellPhone is null)
    and  (cEmail=@Email  or  @Email is null)
    and  (cURL=@URL or @URL is null )/code]
      

  4.   

    select distinct(cLevel) from tb_CustomerHistory 
    where (cAccount=@Account or @Account is null) 
    and (cCompany =@Company or @Company is null)
    and  (cCellPhone=@CellPhone  or @CellPhone is null)
    and  (cEmail=@Email  or  @Email is null)
    and  (cURL=@URL or @URL is null )