存储过程in参数问题?
我之前把我想要的数据都插入了临时表#temp,后来想改成参数写就是得不到想要结果,问一个同事说很简单搞的我不好意思。
1
if((select COUNT(1) from #temp where Operator is not null)>0)
begin
set @setment +=' and operator in(select Operator from #temp where Operator is not null)' //一句代码搞定
end
2
if((select COUNT(1) from #temp where Operator is not null)>0) /现在我想把它变成参数来写
begin
set @selectment+=' or p.Operator in(@Operator)'
set @decment+=',@Operator varchar(200)'
set @setment +=' set @Operator=select TargetUser from #temp where TargetUser is not null' //参数赋值
end
------解决方案--------------------
既然都写到临时表里面了 直接join 不就可以了 为什么还要in 呢