怎样查询数据中带“  '   "的数据比如:类似  ABDE'dsd的数据

解决方案 »

  1.   

    declare @code varchar(120)
    set @code='ABDE''dsd'
    print @codeselect CHARINDEX('''',@code)
    /*
    5
    */
      

  2.   

    create table tb(code varchar(120))
    insert tb select 'ABDE''dsd' union select 'sfs' union select 'assfdf''sdf'
     select * from tb where CHARINDEX ('''',code)>0
     /*
     code
    ABDE'dsd
    assfdf'sdf
    */
    drop table tb
      

  3.   

    table:
    名称
    ass'eddsselect * from table where 名称='ass'edds'类似这样的查询
      

  4.   


    select * from table where 名称='ass''edds'
      

  5.   

    select * from table_name where 名称 = 'ass''edds'   --需要转义一下,用2个'代表一个'