---
title: "DB2 SQL: LTRIM, RTRIM and TRIM best examples"
description: "The SQL functions are highly beneficial for SQL developers and ETL developers. Read best examples on TRIM, LTRIM and RTRIM."
url: https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/
date: 2012-07-04
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/07/db2-strings.jpg?fit=1200%2C700&ssl=1
categories: ["SQL"]
tags: ["SQL Functions"]
type: post
lang: en
---

# DB2 SQL: LTRIM, RTRIM and TRIM best examples

Functions are an important concept in DB2. Look for job requirement for [data warehousing jobs. ](http://www.indeed.com/jobs?indpubnum=6634974704162507&chnl=srinimf)If we [want to](https://srinimf.com/2016/02/09/want-to-excel-in-ims-dc-programming-read-this/) make a report from the data, we use built-in functions [to get](https://srinimf.com/2016/09/22/how-to-analyze-sql-query-the-best-way/) required output. It simplifies your [SQL query](https://srinimf.com/2023/01/21/sql-query-how-to-check-index-space/).

Related[NVL and COALESCE Functions Basic Differences in DB2](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/)

## There are many examples. I am giving my own examples.

“RAMA RAGAVA RANI  “

SELECT **RTRIM**(“RAMA RAGAVA RANI  “) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on right side.

”  RAMA RAGAVA RANI  “

SELECT **LTRIM**(” RAMA RAGAVA RANI”) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on left side.

”  RAMA RAGAVA RANI “

SELECT **TRIM**(” RAMA RAGAVA RANI “) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on both sides.

The above are beautiful examples. You can use extensively. Refer more [built in functions here.](http://bit.ly/2j3y1Ph)

**References**

- [SQL DBA for beginners](https://click.linksynergy.com/link?id=OQ7xCpsijMk&offerid=323058.856424&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fsql-dba-for-beginners%2F)
- [PL/SQL video training for all developers](https://click.linksynergy.com/link?id=OQ7xCpsijMk&offerid=323058.875360&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fplsqltuning%2F)
- [Advanced SQL training for senior developers](https://click.linksynergy.com/link?id=OQ7xCpsijMk&offerid=323058.525156&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fadvanced-sql-tutorial%2F)

**Related Posts**

- [NVL and COALESCE Functions Basic Differences in DB2](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/)DateNovember 8, 2015
- [SQL Make Sure These in Your Course Curriculum](https://srinimf.com/2012/06/26/sql-topics-to-learn-mainframe-and-dwh-professionals/)DateJune 26, 2012
- [SQL Numeric Functions Easy Ways to Use](https://srinimf.com/2018/04/01/sql-query-numeric-function-used-in-real-time-banking-project/)DateApril 1, 2018

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F07%2F04%2Fdb2-sql-ltrim-rtrim-and-trim%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F07%2Fdb2-strings.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=DB2%20SQL%3A%20LTRIM%2C%20RTRIM%20and%20TRIM%20best%20examples)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%20SQL%3A%20LTRIM%2C%20RTRIM%20and%20TRIM%20best%20examples&body=https%3A%2F%2Fsrinimf.com%2F2012%2F07%2F04%2Fdb2-sql-ltrim-rtrim-and-trim%2F&share=email)
-

### Like this:

Like Loading…
