请问如何判断字符串中全部是英文字母?

wangyangcheng 2005-09-17 12:29:02
什么办法效率最高?
谢谢
...全文
668 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
iwl 2005-09-18
  • 打赏
  • 举报
回复
select * from tablename where Lower(Columnname1) like '[a-z]'

或者

用vivianfdlpw() 的方法
vivianfdlpw 2005-09-17
  • 打赏
  • 举报
回复
/*
判断指定字符串中是否全是英文字母(可区分全角字符)
  是,返回1;反之0

  半角英文字母Unicode范围65-90,97-122
全角英文字母Unicode范围65313-65338,65345-65370
*/
create function isletter(@str varchar(8000))
returns int
as
begin
while len(@str)>0
begin
if (unicode(left(@str,1)) not between 65 and 90)
and
(unicode(left(@str,1)) not between 97 and 122)
and
(unicode(left(@str,1)) not between 65313 and 65338)
and
(unicode(left(@str,1)) not between 65345 and 65370)
return 0

set @str=stuff(@str,1,1,'')
end

return 1
end
go

--测试
select dbo.isletter('a1')
select dbo.isletter('1')
select dbo.isletter('a')
select dbo.isletter('a')
wgsasd311 2005-09-17
  • 打赏
  • 举报
回复
又如何判断全是阿拉伯数字呢?=====>
--假设此表主键为id
select a.* from tbname a where not exists(
select * from tbname where id=a.id and 字段 not like '%[0-9]%')

lisiyong 2005-09-17
  • 打赏
  • 举报
回复
判断全是阿拉伯数字:

select * from tablename where Columnname1 not like '%[^0-9]%'
wgsasd311 2005-09-17
  • 打赏
  • 举报
回复
--假设此表主键为id
select a.* from tbname a where not exists(
select * from tbname where id=a.id and 字段 not like '%[a-z,A-Z]%')
lisiyong 2005-09-17
  • 打赏
  • 举报
回复
select * from tablename where Columnname1 like '[a-z]' or Columnname1 like '[A-Z]'
wangyangcheng 2005-09-17
  • 打赏
  • 举报
回复
又如何判断全是阿拉伯数字呢?
天地客人 2005-09-17
  • 打赏
  • 举报
回复
帮UP
MorningTea 2005-09-17
  • 打赏
  • 举报
回复
SQL中有没有办法区分数字和中文字符
URL:http://community.csdn.net/Expert/topic/4218/4218786.xml?temp=.9425012
leon_kin 2005-09-17
  • 打赏
  • 举报
回复
declare @word nchar(1)
set @word='中'
if unicode(@word) between 19968 and 19968+20901
print '汉字'
else
print '不是汉字'
ynmc 2005-09-17
  • 打赏
  • 举报
回复
Learning...
顺顶
wangyangcheng 2005-09-17
  • 打赏
  • 举报
回复
I used ISNUMERIC() function.

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧