SQL code to find upper case values
Yoanna
Posts: 1 New member
Hi guys,
I am writing a select statement that looks through a column with guid strings and returns only those values that contain upper case symbols. The column contains many strings containing both upper and lower case symbols, but I want to extract only those with upper case. I am using MS SQL Management Studio. Your help will be appreciated!
Thanks.
I am writing a select statement that looks through a column with guid strings and returns only those values that contain upper case symbols. The column contains many strings containing both upper and lower case symbols, but I want to extract only those with upper case. I am using MS SQL Management Studio. Your help will be appreciated!
Thanks.
Answers
Note:
jigsaw puzzle
FROM (VALUES --This represents the values in a table
(1,'02830916-85AB-47FF-A2CA-2228441840EE','All UPPER CASE')
,(2,'02830916-85ab-47ff-a2ca-2228441840ee','All LOWER CASE')
,(3,'02830916-85aB-47ff-a2ca-2228441840ee','One UPPER CASE')
)v(RowNum, GUIDString, Explanation)
WHERE GUIDString LIKE '%[A-F]%' COLLATE Latin1_General_BIN
;
FROM (VALUES --This represents the values in a table
(1,'02830916-85AB-47FF-A2CA-2228441840EE','All UPPER CASE')
,(2,'02830916-85ab-47ff-a2ca-2228441840ee','All LOWER CASE')
,(3,'02830916-85aB-47ff-a2ca-2228441840ee','One UPPER CASE')
)v(RowNum, GUIDString, Explanation)
WHERE GUIDString LIKE '%[A-F]%' COLLATE Latin1_General_BIN
;
Here is an example :
SELECT YourGUIDColumn
Rohansnowflake online training
To find uppercase values in a SQL column, you can use the
UPPER
function along with a comparison. Here's an example:Assuming you have a table named
your_table
and you want to find uppercase values in theyour_column
column:In this query:
UPPER(your_column)
converts all values inyour_column
to uppercase.WHERE
clause filters rows where the original value is equal to its uppercase version, meaning it was already in uppercase.Keep in mind that this comparison will only find exact matches between the original and uppercase versions of the values. If you want to find rows where any uppercase letter exists, you might need to use a different approach depending on your SQL database system.
For example, in SQL Server, you can use the
COLLATE
clause with a case-insensitive collation:This query performs a case-sensitive comparison, and if the original and uppercase values match, it implies that the original value is already in uppercase. Adjust the collation according to your specific SQL database system and collation settings.