--1,null where col is null --2,“”(空字符串) where len(col)=0 --3,有值 where col is not null ?
--3,有值 where len(col)>0
where A is null 當A為null時 where A='' 當A為空時 where A='某個值' 當A有值時
if @name is null begin ... end else if @name='' begin ... end else begin .... end
... 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 ...
--1,null
where col is null
--2,“”(空字符串)
where len(col)=0
--3,有值
where col is not null
?
where len(col)>0
where A is null 當A為null時
where A='' 當A為空時
where A='某個值' 當A有值時
if @name is null
begin
...
end
else if @name=''
begin
...
end
else
begin
....
end
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
...