当前位置: 代码迷 >> Sql Server >> 求问like变量的有关问题
  详细解决方案

求问like变量的有关问题

热度:40   发布时间:2016-04-27 13:36:02.0
求问like变量的问题?
[email protected]
在循环中有select语句,如select * from table where a like [email protected]+'%',这样写对吗?
注:[email protected]
不对的话,应该怎么写?

------解决方案--------------------
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+',%'
  相关解决方案