关于SQL中IF语句的使用问题
[解决办法]
--try this
declare @sql_com VARCHAR(2000)
declare @sql_where VARCHAR(2000)
declare @jsbm VARCHAR(10)
set @jsbm='aa'
set @sql_com='select * from tb1 where 1=1 '
select @jsbm as '传回参数'
if (@jsbm = '')
begin
set @sql_where='无字符'
end
else
begin
set @sql_where=@sql_where +' and jsbm = @jsbm '
end
set @sql_com=@sql_com + @sql_where
select @sql_where as '过滤条件'
select @sql_com as '命令部份'