记录中包含着[]这种东西,用
select * from table1 where column1 like '%京工商字[2007]100号%' 得不到结果,
该怎么写呢? 请大家帮忙,谢谢.

解决方案 »

  1.   

    LIKE '[ [ ]'   [
     
    LIKE ']'   ]
     
      

  2.   

    select   *   from   table1   where   column1   like   '%京工商字@[2007]100号%' escape '@'
      

  3.   

    declare @t table (id int,       name  varchar(20),      value varchar(20))
    insert into @t select 1,'甲','京工商字[2007]100号'select * from @t where value like '%[[]2007]%'
      

  4.   

    or
    select   *   from   table1   where   charindex('京工商字[2007]100号',column1)>0 
      

  5.   

    select   *   from   #table1   where   column1   like   '%京工商字/[2007/]100号%' ESCAPE '/'   
      

  6.   

    ]--需要转义
    declare @T table(Col nvarchar(100))
    insert @T select '京工商字[2007]100号'
    select * from @T where Col like '%[2007[]]%'Col                                                                                                  
    ---------------------------------------------------------------------------------------------------- 
    京工商字[2007]100号(所影响的行数为 1 行)
      

  7.   

    select   *   from   table1   where   column1   like   '%京工商字[2007]100号%'
    好象我也遇到过这样的问题
    后来我用charindex来实现的
    select * from table1 where charindex('%京工商字[2007]100号%' ,  column1)>0
    这样就好使了
    不知道为什么
    可能是我写错了吧