exec('select * from table where columnName in(' + cast(@tem as varchar) + ')')

解决方案 »

  1.   

    exec('select * from table where columnName in('+@tem+')')
      

  2.   

    exec('select * from table where columnName in('+@tem+')')
      

  3.   

    declare @tem as varchar(20)
    set @tem = '11,12,13' print('select * from table where columnName in (' + cast(@tem as varchar) + ')')
    /*
    select * from table where columnName in (11,12,13)
    */exec('select * from table where columnName in (' + cast(@tem as varchar) + ')')
      

  4.   

    select * from table where columnName inttostr(@tem as varchar)
      

  5.   

    select * from table where charindex( ',' + columnName + ',', ',' + @tem + ',' ) > 0