SQL Server:IsCharAlpha

发布于 2024-12-10 03:39:10 字数 316 浏览 3 评论 0原文

是否有内置或解决方法技术来确定字符“IsAlpha"?


我看到很多建议都围绕

IF PATINDEX('[a-zA-Z]', @c) > 0
BEGIN
   --It is alpha
END

except that 忽略不在给定范围 AZ 内的字母字符。

Is there a built-in, or workaround technique, to determine if a character "IsAlpha"?


i see a lot of suggestions that revolve around

IF PATINDEX('[a-zA-Z]', @c) > 0
BEGIN
   --It is alpha
END

Except that neglects alpha characters that are not in the given range A-Z.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世态炎凉 2024-12-17 03:39:10

排序规则控制重音符号和变音符号的评估方式,例如 S 是否等于 Š

请注意以下结果...第一个 SELECT 返回 2 个匹配项,第二个仅返回 1 个匹配项:

DECLARE @testTable TABLE (testValue nvarchar(50))

insert into @testTable (testValue) values ('Š')
insert into @testTable (testValue) values ('S')
insert into @testTable (testValue) values ('4')

SELECT 'IsAlpha', testValue 
FROM @testTable 
WHERE PATINDEX('[a-zA-Z]', testValue COLLATE Latin1_General_CS_AS) > 0 

SELECT 'IsAlpha', testValue 
FROM @testTable 
WHERE PATINDEX('[a-zA-Z]', testValue COLLATE LATIN1_GENERAL_BIN) > 0 

您可以在此处找到 SQL Server 2008 中的排序规则列表和简要说明。

Collation controls how accents and diacritics are evaluated, such as whether or not S equals Š.

Note the results for the following... the first SELECT returns 2 matches, the second only returns 1 match:

DECLARE @testTable TABLE (testValue nvarchar(50))

insert into @testTable (testValue) values ('Š')
insert into @testTable (testValue) values ('S')
insert into @testTable (testValue) values ('4')

SELECT 'IsAlpha', testValue 
FROM @testTable 
WHERE PATINDEX('[a-zA-Z]', testValue COLLATE Latin1_General_CS_AS) > 0 

SELECT 'IsAlpha', testValue 
FROM @testTable 
WHERE PATINDEX('[a-zA-Z]', testValue COLLATE LATIN1_GENERAL_BIN) > 0 

You can find a list of collations within SQL Server 2008 and a brief descripition here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文