日期:2014-05-17 浏览次数:20516 次
declare @res varchar(100),@tsql varchar(6000)
set @res='1 2 3 4 5'
select @tsql='select * from Student where name like ''%'
+replace(@res,' ','%'' or name like ''%')+'%'' '
print @tsql
-- 结果
/*
select * from Student where name like '%1%' or name like '%2%' or name like '%3%' or name like '%4%' or name like '%5%'
*/