The UPPER()
function in SQL Server is used to convert a string to uppercase letters. It takes a single string as input and returns the string with all characters converted to uppercase.
Syntax:
UPPER(string_expression)
string_expression
: This is the string you want to convert to uppercase. It can be a literal string, a column containing string data, or an expression that evaluates to a string.
Example Usage:
1. Basic Example:
SELECT UPPER('hello world') AS UppercaseString;
Result:
UppercaseString
---------------
HELLO WORLD
2. Using with a Table Column:
Suppose you have a table named Employees
with a column FirstName
. To retrieve all first names in uppercase:
SELECT UPPER(FirstName) AS UppercaseName
FROM Employees;
3. Combined with Other Functions:
You can use UPPER()
in conjunction with other SQL functions, like CONCAT
:
SELECT CONCAT(UPPER(FirstName), ' ', UPPER(LastName)) AS FullName
FROM Employees;
Notes:
- The
UPPER()
function does not modify the original data in the table; it only affects the result set. - It works only on alphabetic characters, leaving numeric and special characters unchanged.
If you need further examples or have a specific use case in mind, feel free to ask!
No comments:
Post a Comment