select * from table where charindex('''',colname) > 0
select * from tablename where charindex('''',col,1)>=1
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
charindex('''',字段名) > 0 这么晚了 ^_^
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
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
你要查一个单引号,他们写这么多,你就认为不对了? 测试下再说吧另一个写法: colname like '%''%'
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
这么晚了 ^_^
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
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
测试下再说吧另一个写法:
colname like '%''%'
colname like '%''%'
这就是一个单引号 ^_^"注意单引号用转义字符就可以了"-_-