怎么能查到一个字段中含有单引号的记录啊? 这个引号是英文的。

解决方案 »

  1.   

    select * from table where charindex('''',colname) > 0
      

  2.   

    select * from tablename where charindex('''',col,1)>=1
      

  3.   


    create table #t(id int,字段名 varchar(100))insert into #t select 1,'abc'
    insert into #t select 1,'ab''c'select * from #t--搜索含有单引号的记录
    select * from #t where charindex('''',字段名) > 0
    drop table #t
      

  4.   

    charindex('''',字段名) > 0
    这么晚了  ^_^
      

  5.   

    create table #t(id int,字段名 varchar(100))insert into #t select 1,'abc'
    insert into #t select 2,'ab''c'
    insert into #t select 3,'a''''b''c'
    insert into #t select 3,'ab''''''c'select * from #t--搜索列[字段名]只含有一个单引号的记录
    select * from #t where len(字段名)-len(replace(字段名,'''',''))=1drop table #t
      

  6.   

    create table #t(id int,字段名 varchar(100))insert into #t select 1,'abc'
    insert into #t select 1,'ab''c'
    insert into #t select 1,'a''b''c'select * from #t--搜索含有单引号的记录
    select * from #t where charindex('''',字段名) > 0--搜索只含有单引号的记录
    Select * from #t 
    where Len([字段名])-Len(Replace([字段名],'''',''))=1drop table #t
      

  7.   

    你要查一个单引号,他们写这么多,你就认为不对了?
    测试下再说吧另一个写法:
    colname like '%''%'
      

  8.   

    楼上这种写法查出的是含有单引号,但不一定是一个单引号
    colname like '%''%'
      

  9.   

    charindex('''',字段名) > 0
    这就是一个单引号  ^_^"注意单引号用转义字符就可以了"-_-
      

  10.   

    晕,现在才搞明白楼主意思?a'b  oka'bcccc'd          ng?