exec('select * from table where columnName in('+@tem+')')
exec('select * from table where columnName in('+@tem+')')
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) + ')')
select * from table where columnName inttostr(@tem as varchar)
select * from table where charindex( ',' + columnName + ',', ',' + @tem + ',' ) > 0
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) + ')')