在SQL语句中如何检查某个字段的值是否有非法字母(100分)

  • 主题发起人 主题发起人 hn_chx
  • 开始时间 开始时间
H

hn_chx

Unregistered / Unconfirmed
GUEST, unregistred user!
ACCESS表里的InvID字段的值为18位长度的字符串(由数字组成,要求不能有非法字母),请问如何在SQL语句中提取出该字段有非法字母的记录
 
非法字母 是怎麼定義的?
 
給你個函數; 參考參考阿
function isvalid( const s: string):boolean;
const invalidchar : array[0..8] of char=('/','/','.','*'....等等)
var
i:integer;
begin
result := length(s)<=max_path;
if not result then exit;
for i:=low(invalidchar) to high(invalidchar) do
begin
result := pos(invalidchar,s)=0
if not result then break;
end;
end;
 
1、非法字母定义就是里面有非数字的字符

2、我要求的是在SQL语句中实现查找该字段值有非法字母的记录
 
非法的意思等于犯罪
 
declare @i int
set @i = 1
while @i < len('sss')
begin
if ascii(substring('sss', @i, 1)) > 48 and ascii(substring('sss', @i, 1)) < 57
begin
set @i = @i + 1
continue
end
else
begin
break
return -1
end
end
大致这样吧
 
谢谢各位的帮助, 我已找到方法

以下语句就是我想要的结果
select NewInvID as 发票号 from InvID where NewInvID like "%[A-Z]%"
 
后退
顶部