存储过程
@a为外部传入进来的一个字符串,如'102,2033,561'等等,里面全部是数字
select xx from t1 where id in(@a)
出错,
因为id是int型,这种情况有没有什么好的处理办法?
select xx from t1 where id in(102,2033,561)   不会出错select xx from t1 where cast(id as varchar) in('102','2033','561')   不会出错

解决方案 »

  1.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  2.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  3.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  4.   

    exec('select   xx   from   t1   where   id   in' + (@a))
      

  5.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  6.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  7.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  8.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  9.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  10.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  11.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  12.   

    exec('select   xx   from   t1   where   id   in('+@a+')')
      

  13.   

    感动,
    CSDN现在才是人气时候?
    本来打算明天起来看看有没有回帖的....
    致敬..