--> 测试数据:[tb] if object_id('[tb]') is not null drop table [tb] go create table [tb]([name] varchar(5)) insert [tb] select '张三#' union all select '李四2' union all select 't王五' union all select '*赵六' union all select '马p七' union all select '刘八'select * from [tb] where patindex('%[^吖-做]%',name) = 0 ------------------------ 刘八
select * from tb where name not like '%[0-9]%' and not like '%[a-z]%' and not ...
select * from [tb] where patindex('%[^吖-做]%',name) = 0
where patindex('%[^啊-坐]%',name) = 0
select * from DGMOCDS where patindex( '%[0-9,a-z,A-Z]%' ,ds004)>0
啊寫錯select * from DGMOCDS where patindex( '%[0-9,a-z,A-Z]%' ,ds004)=0 才對吧
select * from tb where datalength(name)=len(name)*2
DATALENGTH 返回字节数 汉字占两个字节
- -雙字符符號也一大堆拉,, select DATALENGTH(' ') 麻煩啊- -
鬱悶了 這樣成不 select * from DGMOCDS where patindex('%[-Z]%',ds004)=0
貌似還是不行,,算了,,我放棄。,,等高手,, 你實在比較急可以考慮一個一個在後面加- - select * from DGMOCDS where patindex('%[0-9,a-z,A-Z,*,},{]%' ,ds004)=0 之類的- -死人嘎
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([name] varchar(5))
insert [tb]
select '张三#' union all
select '李四2' union all
select 't王五' union all
select '*赵六' union all
select '马p七' union all
select '刘八'select * from [tb]
where patindex('%[^吖-做]%',name) = 0
------------------------
刘八
select * from DGMOCDS
where patindex( '%[0-9,a-z,A-Z]%' ,ds004)>0
where patindex( '%[0-9,a-z,A-Z]%' ,ds004)=0
才對吧
where datalength(name)=len(name)*2
select DATALENGTH(' ')
麻煩啊- -
這樣成不
select * from DGMOCDS
where patindex('%[-Z]%',ds004)=0
你實在比較急可以考慮一個一個在後面加- -
select * from DGMOCDS
where patindex('%[0-9,a-z,A-Z,*,},{]%' ,ds004)=0
之類的- -死人嘎