日期:2014-05-18  浏览次数:20624 次

求问like变量的问题?
如游标变量@test
在循环中有select语句,如select * from table where a like '%'+@test+'%',这样写对吗?
注:a列可能包含@test
不对的话,应该怎么写?

------解决方案--------------------
update tablea set flag = 1 
from tablea a , tableb b
where charindex(','+b.b+',' ,','+ replace(replace(replace(replace(a.a,'、',','),',',','),'/',''),'\','')+',' ) > 0

或者:
update tablea set flag = 1 
from tablea a , tableb b
where ','+ replace(replace(replace(replace(a.a,'、',','),',',','),'/',''),'\','')+',' like '%,'+b.b+',%'