6
I have a field in a table that must be filled all in lower case, but the user being user filled some lines in upper case. I want to identify what records are like this so I can request correction.
I have how to test if my string is all uppercase?
6
I have a field in a table that must be filled all in lower case, but the user being user filled some lines in upper case. I want to identify what records are like this so I can request correction.
I have how to test if my string is all uppercase?
8
You can use the COLLATE LATIN1_GENERAL_CS_AI in its validation as follows:
DECLARE @texto_normal VARCHAR(100);
DECLARE @texto_minusculo VARCHAR(100);
SET @texto_normal = 'Normal';
SET @texto_minusculo = 'minusculo';
IF LOWER(@texto_normal) <> @texto_normal COLLATE LATIN1_GENERAL_CS_AI
BEGIN
PRINT '@texto_normal tem maiúsculas';
END;
IF LOWER(@texto_minusculo) <> @texto_minusculo COLLATE LATIN1_GENERAL_CS_AI
BEGIN
PRINT '@texto_minusculo tem maiúsculas';
END;
Or to use in a query:
SELECT *
FROM tabela t
WHERE LOWER(t.campo) <> t.campo COLLATE LATIN1_GENERAL_CS_AI;
The CS_ selector says the text is case sensitive.
Reference: Collation and Unicode Support
+1 mass ......
Thanks @sorack. I got what I wanted using the query you reported.
@Rafaeldantas if the answer met you, mark it as correct so that other users can benefit from your question
Browser other questions tagged sql database sql-server sql-server-2016
You are not signed in. Login or sign up in order to post.
You want to test whether it has uppercase letters or all uppercase letters?
– Jeferson Almeida
Imagine you have that value in your field:
TEXTO Correto, would be either right or wrong?– Marconi
The need is to find out if the field has the whole text in Maíusculo.
– Rafael Dantas