select status,* from T_HR_Org where charindex(','+status+',', ','+@s+',')>0  

解决方案 »

  1.   

    declare @s varchar(500) 
    set @s='1,2,6,8' 
    set @s=substring(@s,1,(len(@s))) 
    print @s 
    select status,* from T_HR_Org where charindex(','+status+',', ','+@s+',')>0
      

  2.   

    declare @s varchar(500) 
    set @s='1,2,6,8' 
    set @s=substring(@s,1,(len(@s))) EXEC('select status,* from T_HR_Org where status in('+@s+')')  --或
    select status,* from T_HR_Org where charindex(','+status+',', ','+@s+',')>0  
      

  3.   

    数值类型不能直接使用in查询的.
    select status,* from T_HR_Org where charindex(','+status+',', ','+@s+',')>0