--该问题问过好多次了。declare @t table(id int, a1 varchar(20))
insert into @t select 1,'_38_55_456_'
union all select 2,'_22_45_99_'
union all select 3,'_57_8_'
select * from @t where charindex('_8_',a1)>0
/*
id          a1
----------- --------------------
3           _57_8_(1 行受影响)
*/

解决方案 »

  1.   

    select * from b1 Where a1 like '%[_]8[_]%'
      

  2.   

    select * from a1 where charindex('_8_',a1)>0
      

  3.   

    用[]括起來Create Table b1 (ID Int,a1 Varchar(1000))
    Insert b1  Select 1,'_38_55_456_'
    Union All Select 2,'_22_45_99_'
    Union All Select 3,'_57_8_'
    GO
    select * from b1 Where a1 like '%[_]8[_]%'
    GO
    Drop table b1
    --Result
    /*
    ID a1
    3 _57_8_
    */
      

  4.   

    declare @tab table(id int,a1 varchar(20))insert @tab values(1,'_38_55_456_')
    insert @tab values(2,'_22_45_99_')
    insert @tab values(3,'_57_8_')select * from @tab where a1 like '%_8_%'--这个你想要的
    select * from @tab where charindex('_8_',a1,0)>0
      

  5.   

    select * from a1 where patindex('%_8_%',a1)>0
      

  6.   

    但是经过测试,下面一句结果不对,查出两条记录。
    select * from a1 where patindex('%_8_%',a1)>0