因为有多个变量呀。假如有三个变量,@DJ,@DH,@MCh
这三个值都可以输入,也可能不输入,
那我是必要判断这几个值有没有输入
if @DJ <> ''
begin
if @DH <> ''
begin
if @MCH <> ''
begin
....
end
end
else
begin
end
end
else
begin
...
end我是不是就需要这样写了呢?这样写就太麻烦了。并且我这里不能用Like @DJ + '%'
这种形式写的。必须要用=,那要么只能用上面的形式写
这三个值都可以输入,也可能不输入,
那我是必要判断这几个值有没有输入
if @DJ <> ''
begin
if @DH <> ''
begin
if @MCH <> ''
begin
....
end
end
else
begin
end
end
else
begin
...
end我是不是就需要这样写了呢?这样写就太麻烦了。并且我这里不能用Like @DJ + '%'
这种形式写的。必须要用=,那要么只能用上面的形式写
set @s = 'select * from table1 A,table2 B where A.ID = B.ID 'if(@DJ is not null and @DJ!='')
set @s = @s + 'and a.DJ='''+@DJ+''''exec(@s)