declare @str varchar(500)
set @str='1,2,3,4,5,6,7'
create table #temp (id int)
declare @aaa varchar(8000)
set @aaa='insert #temp select * from (select '''+replace(@str,',',''' as str union all select ''')+''') a'
exec(@aaa)
现在要得到这样一个结果集,将表.classid在@str里出现过(@str是外界传过来的一个参数)的记录找出来,请问我该怎么做?
select * from 你的表 where exists (select 1 from #temp where 你的表.classid = #temp.id )