Jai*_*Jai 3 regex sql sql-server-2008
这就是我的想法,我知道在这个领域,第一个单词总是至少2个字符.
Select *
From Table!
where SUBSTRING(Name, 1, 3) like '[A-Z]'
Run Code Online (Sandbox Code Playgroud)
但是,这会带回非大写字母的任何想法吗?
Select ...
From MyTable
Where Name Not Like '%[^A-Z]%' Collate SQL_Latin1_General_CP1_CS_AS
Run Code Online (Sandbox Code Playgroud)
应该注意的是,这也将排除AZ之外的数字和字符.如果你想要包含非拉丁大写字符,你真的需要使用该Upper函数和Collate谓词:
Select ...
From MyTable
Where Name = Upper(Name) Collate SQL_Latin1_General_CP1_CS_AS
Run Code Online (Sandbox Code Playgroud)
测试脚本:
With TestData As
(
Select '012324' As Name
Union All Select 'ABC'
Union All Select 'abc'
Union All Select 'aBc'
Union All Select 'ABé'
Union All Select 'ABÉ'
)
Select *
From TestData
Where Name = UPPER(Name) Collate SQL_Latin1_General_CP1_CS_AS
Run Code Online (Sandbox Code Playgroud)
结果:
012324
ABC
ABÉ
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7592 次 |
| 最近记录: |