我需要在数据库表中找到具有大写值字段的行。
E.g.: select * from Cust where Surname like 'COnTAiNS UpPERcASE VaLUeS'
任何帮助都将不胜感激。
AJ
答案 0 :(得分:13)
您可以使用以下方式进行二进制比较:
select *
from Cust
where cast(Surname as varbinary(120)) != cast(lower(Surname) as varbinary(120))
答案 1 :(得分:3)
另一种方式
SELECT *
FROM Cust
WHERE Surname NOT LIKE '%[^A-Z]%' COLLATE Latin1_General_BIN
答案 2 :(得分:1)
你可以这样做:
SELECT
CASE WHEN BINARY_CHECKSUM('yourStriNg') = BINARY_CHECKSUM(LOWER('yourStriNg'))
THEN 0
ELSE 1
END
...
其余的SQL语句
答案 3 :(得分:0)
尝试从给定的字符串值中仅提取大写字母:
Declare @Val Varchar(100)
Set @Val='MicrosoftAsp.NeT4You'
--Return Val
Declare @RetCapWord varchar(100)
Set @RetCapWord=''
;WITH CTE AS
(
Select @Val As oldVal,1 As TotalLen,SUBSTRING(@Val,1,1) As newVal,
ASCII(SUBSTRING(@Val,1,1)) As AsciVal
UNION ALL
Select oldVal,TotalLen+1 As TotalLen,
substring(@Val,TotalLen+1,1) As newVal,
ASCII(SUBSTRING(@Val,TotalLen+1,1)) As AsciVal
From CTE
where CTE.TotalLen<=LEN(@Val)
)
Select @RetCapWord=@RetCapWord+newVal
From CTE
Inner Join master..spt_values as m on CTE.AsciVal=m.number and CTE.AsciVal between 65 and 90
Select @RetCapWord
答案 4 :(得分:0)
这对我有用
SELECT * FROM agents
WHERE email REGEXP BINARY '[A-Z]'
答案 5 :(得分:0)
这可能过于简单,但适用于我的用例:
SELECT *
FROM Cust
WHERE Surname != LOWER(Surname)