I have a table with a varchar type column. I want to select values from this column which start with a capital letter only.
For example
MyTable
Col1 Col2
Argentina 2
Brasil 3
uruguay 4
I want my select query to return:
Argentina
Brasil
Use the INITCAP() function to convert a string to a new string that capitalizes the first letter of every word. All other letters will be lowercase. This function takes one parameter as a string and changes the capitalization for each word as described.
We use SQL UPPER function to convert the characters in the expression into uppercase. It converts all characters into capital letters.
If you want to display a string in uppercase, use the SQL UPPER() function. This function takes only one argument: the string column that you want to convert to uppercase.
This is a bit of a pain. You can use ASCII()
or COLLATE
, but these depend on how the data is stored. For varchar()
and char()
, this will work:
where ASCII(left(col1, 1)) between ASCII('A') and ASCII('Z')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With