The TRIM function removes leading and trailing spaces from a text value in database systems that support the function.
Unwanted spaces can cause inconsistent values, failed comparisons, duplicate-looking records, and data-quality problems.
Remove extra spaces from employee names.
SELECT
TRIM(EmployeeName) AS EmployeeName
FROM Employees;
TRIM is widely used during data cleaning, customer-data preparation, employee-data validation, and import processes.
- TRIM removes leading and trailing spaces.
- It is useful for data cleaning.
- It can improve text comparisons.
- It does not generally remove spaces inside text.
- Syntax can vary for advanced trimming requirements.
What does TRIM do?
TRIM removes unwanted leading and trailing spaces from text values.
Does TRIM remove spaces between words?
Normally no. TRIM primarily removes spaces from the beginning and end of the text.