模糊查询存储过程-一直想不通为什么
我写了一个存储过程   用的模糊查询   然后在c#   vs2005中调用 
 为什么查询的时候只能输入最后一个字查询 
 比如   dw_cz为      谢谢你                        我只能用      你            才能查询到记录,用   谢谢   或   谢   都不行   
 CREATE   PROCEDURE   FindStr 
 @InfoStr   nvarchar(20) 
 AS 
 set   @InfoStr=    '% '+@InfoStr+ '% ' 
 select    
                         xh,rq,dw_cz,cx,jsdh,zynr,fklb,fwzy,wxzf,ssje,bz    
                   from   Tdcw    
 where   dw_cz   like   @InfoStr 
 GO   
 从下午搞到半夜了      也没有眉目      谢谢大家了
------解决方案----------------------直接用下面语句试试   
 select  
         xh,rq,dw_cz,cx,jsdh,zynr,fklb,fwzy,wxzf,ssje,bz  
 from Tdcw  
 where dw_cz like  '%谢% '
------解决方案--------------------select * from ta where patindex( '% '+@InfoStr+ '% ',dw_cz)> 0
------解决方案--------------------楼主,你的存储过程应该没有问题的!你调试一下这个   
 create table aa(dd varchar(50)) 
 insert aa select  '你好 ' 
 union all select  '谢谢你 ' 
 union all select  'wq谢谢你 ' 
 union all select  '谢谢你ds ' 
 union all select  '就是你 ' 
 go   
 declare  @InfoStr nvarchar(20) 
 set @InfoStr= '谢谢 ' 
 set @InfoStr=  '% '+@InfoStr+ '% ' 
 select dd  from aa  
 where dd like @InfoStr 
 GO 
 drop table aa