Beginner

231. LTRIM Function

Learn how to remove unwanted spaces from the beginning of text values.

📘 Lesson 231 of 728 ⏱ 8 min 🎯 Beginner

The LTRIM function removes leading spaces from a text value. The exact behavior and supported options can vary between database systems.

Leading spaces can create inconsistent values and cause problems when comparing, joining, or displaying text data.

Remove unwanted spaces before employee names.

SQL
SELECT
    LTRIM(EmployeeName) AS CleanName
FROM Employees;

LTRIM is useful during data cleansing, migration, ETL processes, and text standardization.

  • LTRIM removes leading spaces.
  • It does not primarily target trailing spaces.
  • It is useful for data cleansing.
  • Syntax and extended behavior vary by database.
  • It can improve text matching.
What does LTRIM do?

LTRIM removes leading spaces from a text value.

Why use LTRIM?

It helps clean text values that contain unwanted spaces at the beginning.

Have you finished this lesson?

Introduction to SQL – All Lessons