SQL cambiar un valor a mayúsculas o minúsculas


¿Cómo hacer que un campo en una instrucción sql select esté en mayúsculas o minúsculas?

Ejemplo:

Seleccione el nombre de la persona

¿Cómo hago que firstname siempre devuelva mayúsculas y del mismo modo siempre devuelva minúsculas?

Author: Joshua Hudson, 2008-12-04

5 answers

SELECT UPPER(firstname) FROM Person

SELECT LOWER(firstname) FROM Person
 96
Author: Jared,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-12-04 17:07:09

LCASE o UCASE respectivamente.

Ejemplo:

SELECT UCASE(MyColumn) AS Upper, LCASE(MyColumn) AS Lower
FROM MyTable
 16
Author: Stephen Wrighton,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-12-04 17:10:41

SQL SERVER 2005:

print upper('hello');
print lower('HELLO');
 5
Author: Cirieno,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-12-04 17:05:18

Puedes usar LOWER function y UPPER function. Como

SELECT LOWER('THIS IS TEST STRING')

Resultado:

this is test string

Y

SELECT UPPER('this is test string')

Resultado:

THIS IS TEST STRING
 1
Author: Muhammad Awais,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-14 06:55:39

Puedes hacer:

SELECT lower(FIRST NAME) ABC
FROM PERSON

NOTA: ABC se utiliza si desea cambiar el nombre de la columna

 0
Author: Xyed Xain Haider,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-08 03:25:52