if @name=' '
begin 
end
就可以了吧

解决方案 »

  1.   


    --1,null 
    where col is null
    --2,“”(空字符串) 
    where len(col)=0
    --3,有值 
    where col is not null
    ?
      

  2.   

    --3,有值 
    where len(col)>0 
      

  3.   


     where A is null   當A為null時
      where A=''       當A為空時
      where A='某個值'  當A有值時
      

  4.   


    if @name is null
    begin
        ...
    end
    else if @name=''
    begin
        ...
    end
    else
    begin
        ....
    end  
      

  5.   

    ...
    IF isnull(@name,'')<>'' SET @sql=@sql+' AND E_name LIKE ''%'+@name+'%'' ' 
    IF isnull(@did,'')<>'' SET @sql=@sql+' AND E_Did ='+@did 
    IF isnull(@work,'')<>'' SET @sql=@sql+' AND E_work LIKE ''%'+@work+'%'' ' 
    IF isnull(@rid,'')<>'' SET @sql=@sql+' AND E_Rid ='+@rid 
    ...