22,209
社区成员
发帖
与我相关
我的任务
分享
...WHERE PATINDEX('%[0-9a-z_]%',a)=0 AND PATINDEX('%[^吖-座]%',a)=1
--TRY
select * from [t1] WHERE PATINDEX('%[0-9a-z_吖-座]%',c)=0
PATINDEX('%[^吖-座]%',@S)
create table [t1]([c] varchar(6))
insert [t1]
select 'aaa' union all
select 'bcds' union all
select 'a1' union all
select '啊' union all
select '^%' union all
select 'ew1' union all
select '344' union all
select '__' union all
select '213_21' union all
select 'a_2' union all
select 'd' union all
select 'ddd' union all
select '电风扇'
select * from [t1] where patindex('%[a-z,0-9,_]%',c)=0
drop table t1
/*
c
------
啊
^%
电风扇
(所影响的行数为 3 行)
*/
select * from [t1] WHERE PATINDEX('%[^0-9a-z_]%',c)=1
/**
c
------
啊
^%
电风扇
(所影响的行数为 3 行)
**/
... WHERE PATINDEX('%[0-9a-z_]%',c)=0
--> 测试数据:[t1]
if object_id('[t1]') is not null drop table [t1]
create table [t1]([c] varchar(6))
insert [t1]
select 'aaa' union all
select 'bcds' union all
select 'a1' union all
select '啊' union all
select '^%' union all
select 'ew1' union all
select '344' union all
select '__' union all
select '213_21' union all
select 'a_2' union all
select 'd' union all
select 'ddd' union all
select '电风扇'
select * from [t1]
where patindex('%[a-z,0-9]%',c)=0
and charindex('_',c)=0
----------------------
啊
^%
电风扇
select * from t1
where patindex('%[a-z]%',c)=0 and patindex('%[0-9]%',c)=0
and charindex('_',c)=0