The LOWER() function in SQL Server is used to convert all uppercase characters in a string to lowercase. This function is commonly used for case-insensitive comparisons, formatting, or standardizing string data.
Syntax:
LOWER(string_expression)
string_expression: The input string or column value that you want to convert to lowercase.
Example Usage:
1. Convert a single string to lowercase:
SELECT LOWER('SQL SERVER FUNCTION');
-- Output: 'sql server function'
2. Use with a table column:
SELECT LOWER(ColumnName) AS LowercaseColumn
FROM TableName;
3. Use for case-insensitive comparisons:
SELECT *
FROM Users
WHERE LOWER(Username) = 'john_doe';
This ensures the comparison works regardless of the case in the Username column.
Notes:
- Non-alphabetic characters (e.g., numbers, symbols) remain unchanged.
- If the input is
NULL, the function returnsNULL.
The LOWER() function is a helpful tool when working with case-insensitive data or ensuring uniformity in string values.
No comments:
Post a Comment